Why doesn’t ‘continue’ work in page?

get_the_terms returns an array of terms – so $terms is an array. Therefore, your condition: if( $terms->slug != ‘product-gallery’ ) will always return false, and therefore skip every post every time. Try if ( in_array( ‘product-gallery’, $terms ) ) continue; The above is untested.

Get markup for post without loading into the template

I couldn’t figure out a WordPress way to do this and looking at the WP source, it looks like this probably will never really be possible. However, I was able to get a solution using vanilla PHP by redirecting standard output into a buffer and loading the buffer into a variable. $listings = new WP_Query(…); … Read more

WordPress loop is not working

custom-header.php <!– Start Top Header affix nav–> <div id=”affix” data-spy=”affix” data-offset-top=”94″ data-offset-bottom=”0″> <!– **** START – NAVBAR SCROLLSPY FIX DO NOT REMOVE **** –> <div id=”top” class=”hide”></div> <!– **** END – NAVBAR SCROLLSPY FIX DO NOT REMOVE **** –> <!– **** START – NAV **** –> <nav class=”navbar navbar-default navbar-shrink”> <div class=”container”> <div class=”navbar-header”> <!– … Read more

get_posts() forcing ignore sticky posts on main loop

From the function reference for get_posts(): For full parameters list see WP_Query. From the WP_Query reference: ignore_sticky_posts (boolean) – ignore sticky posts or not (available with Version 3.1, replaced caller_get_posts parameter). Default value is 0 – don’t ignore sticky posts. Note: ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky … Read more

Comments_template doesn’t work

Seems to me like you are trying to use the comments template out of context. The codex states: Loads the comment template. For use in single Post and Page displays. Will not work outside of single displays unless $withcomments is set to “1”. Unless you have a is_single() on the index.php or use the $withcomments … Read more

Can’t grab author info outside of the loop

For your author box to work, it needs to be inside the loop. You have one fundamental flaw though with your second loop. You are currently using two different loops in one, the first one being the main loop, and the second one a custom loop to fetch related posts As it stand, and where … Read more

Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis

For anyone with the same problem, here’s the answer. I finally figured it out. // Display Profile Sidebar ACF add_action(‘genesis_sidebar’, ’employee_title’); function profile_photo() { if ( is_singular(‘profile’) && genesis_get_custom_field(’employee_title’) ) echo ‘<div id=”employee-title”> ‘. genesis_get_custom_field(’employee_title’) .'</div>’; } This is the the hook location in Genesis where the custom field data needs to output to: genesis_sidebar. … Read more

Add Class according to the order of appearance

Just create an array with your classes and loop through alongside with the main loop: function custom_top_products() { $classes = array( ‘first’, ‘second’, ‘third’, ‘fourth’, ‘fifth’ ); $classes_count = count( $classes ); $posts = new WP_Query( array( ‘post_type’ => ‘products’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘comment_count’, ‘posts_per_page’ => 5 ) ); $i = 0; ?><div … Read more