First custom field value (out of several) displayed twice after query

I managed to fix it! As I suspected it had nothing to do with the code relating to $number, but rather the echo call before it. My initial code looked like this (I’m skipping part of the loop content to keep it simple): echo ‘<p style=”color:grey;font-size:11px;margin:0;”>(‘ . $number = intval(get_post_meta(get_the_ID(), ‘number’, true)); if($number > 1){ … Read more

Why is my category template ignoring post type?

Your issue is definitely caused by the lack of a pre_get_posts filter. Try this in your theme/functions.php: // so event cpt is found on assigned cat archive page function jdk540_event_query_post_type($query) { if ( ! is_admin() ) { if( is_category() || is_tag() && $query->is_main_query() && empty( $query->query_vars[‘suppress_filters’] ) ) { $post_type = get_query_var(‘post_type’); if($post_type) $post_type = … Read more

Breaking up CPT output into two columns

Don’t run the query twice. Use get_posts($args) instead of new WP_Query. Then use array_slice() to generate to arrays of equal length and loop through them that way. array_slice() help: https://stackoverflow.com/questions/5393028/how-can-i-take-an-array-divide-it-by-two-and-create-two-lists