This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$terms = get_terms( array( ‘taxonomy’ => ‘research-categories’, ‘hide_empty’ => false ) ); | |
foreach ( $terms as $term ) { | |
echo $term->name; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$post_id = (int) $_POST['post_id']; | |
$query = new WP_Query( array( 'p' => $post_id ) ); | |
if( $query->have_posts() ) { | |
while ( $query->have_posts() ) { | |
$query->the_post(); | |
write_log( array( 'is post' , get_post_format() ) ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$the_results; | |
function only_run_once() { | |
if ( isset($the_results) ) { | |
return $the_results; | |
} | |
// do stuff | |
$the_results = $some_result_value; | |
return $the_results; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: My Page Template | |
*/ | |
?> | |
<?php // the_post() already uses `global $post;`, so why is it needed again on line 11 in content-my_page.php? ?> | |
<?php while (have_posts()) : the_post(); ?> | |
<?php get_template_part('templates/page', 'header'); ?> | |
<?php get_template_part('templates/content', 'my_page'); ?> | |
<?php endwhile; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="content-main"> | |
<?php | |
// check if the flexible content field has rows of data | |
if( have_rows('flexible_blocks') ): | |
// loop through the rows of data | |
while ( have_rows('flexible_blocks') ) : $row = the_row(); | |
switch (get_row_layout()) { | |
case 'inserted_content': | |
global $post; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE development; | |
SELECT wp_posts.ID FROM wp_posts | |
INNER JOIN | |
wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id | |
INNER JOIN | |
wp_term_taxonomy ON (wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id) | |
INNER JOIN | |
wp_terms ON (wp_terms.term_id = wp_term_taxonomy.term_id) | |
WHERE 1=1 AND ( | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// hide Yoast SEO from non-admin | |
function hide_yoastseo() { | |
if ( !current_user_can( 'administrator' ) ) : | |
remove_action('admin_bar_menu', 'wpseo_admin_bar_menu',95); | |
remove_menu_page('wpseo_dashboard'); | |
endif; | |
} | |
add_action( 'admin_init', 'hide_yoastseo'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('acf/prepare_field', 'acf_prepare_field__inject_form_fields'); | |
function acf_prepare_field__inject_form_fields( $field ) { | |
if ( ! is_admin() ) { | |
// look for the field AFTER where we want to inject something | |
// I used a switch to make it easier to react to multiple insertion points | |
switch ($field['key']) { | |
case 'field_123a456b78c90': | |
acf_form_inject__excerpt(); | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $field = get_field_object('field_123a456b78c90'); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// demo: http://codepen.io/JoelStransky/pen/VKPVAG | |
// breakpoint list ('column type', 'screen breakpoint', 'container width @ break point') | |
$breakpoints: ( ('xs', $screen-xs, $screen-xs), ('sm', $screen-sm, $container-sm), ('md', $screen-md, $container-md), ('lg', $screen-lg, $container-lg) ); | |
@mixin make-fixed-grid() { | |
@each $item in $breakpoints { | |
@media (min-width: #{nth($item, 2)} ) { | |
// background: red; | |
@include make-fixed-grid-columns( $grid-columns, nth($item, 1), width, nth($item, 3) ); | |
} |