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

Custom Query include private posts in pagination count calculations?

If you’re running this custom query in place of the normal main query, you should instead alter the main query before posts are fetched, via the pre_get_posts action. This would go in your theme’s functions.php, or a custom plugin: function wpd_private_posts_in_categories( $query ) { if ( $query->is_category() && $query->is_main_query() ) { $query->set( ‘post_status’, array(‘private’, ‘publish’) … Read more

How to do a wp_query with two acf-fields, sorting on one of them

You are just confusing the array levels, ordering is not done inside the meta_query level but on the main query level. It is the difference between two classes: https://codex.wordpress.org/Class_Reference/WP_Query https://codex.wordpress.org/Class_Reference/WP_Meta_Query Also, as the meta query codex says: “Custom field value can be an array only when compare is ‘IN’, ‘NOT IN’, ‘BETWEEN’, or ‘NOT BETWEEN’”… … Read more