How to sort a WP_Query array by post_name after an array_merge();
How to sort a WP_Query array by post_name after an array_merge();
How to sort a WP_Query array by post_name after an array_merge();
Are you using a checkbox or similar for the ‘acf_platform’ field using ACF for more than one selection? Advanced Custom Fields stores these as a serialised array, so a meta_query with ‘compare’ => ‘=’ may not work. The ACF documentation suggests using ‘compare’ => ‘LIKE’ $args = array( ‘meta_query’ => array( array( ‘key’ => ‘field_name’, … Read more
You can use a conditional tag with the pre_get_posts action hook like this from your functions file. add_action( ‘pre_get_posts’, ‘vm_get_shows’ ); function vm_get_shows ( $query ) { if ( !is_admin() && $query->is_main_query() && is_home() ) { $query->set(‘post_type’, ‘shows’ ); } }
Use this for pagination <?php $paged = ( get_query_var( ‘paged’ ) ) ? absint( get_query_var( ‘paged’ ) ) : 1; $mostpopular_args=array( ‘post_type’ => ‘post’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘view_count’, ‘paged’ => $paged, ‘posts_per_page’ => ’10’, ); $wp_query = new WP_Query($mostpopular_args); while ($wp_query->have_posts()): $wp_query->the_post(); get_the_title(); endwhile; global $wp_query; $big = 999999999; // need an unlikely … Read more
You can get same result by outputting values from PHP array. Since it is multicolumn array, you will need to run foreach loop and get values of each child item. Mostly it’s standard PHP stuff, nothing special. Although earlier you did not need to supply post ID in each WordPress function since you were using … Read more
WP_Query is being reset after tag (using chaining method)
Ok, the problem came from the fact I was looping on categories to get the matching post. What I had to do was to get the desired categories and use it in my $args + some adjustments. <?php // Get the parent cat thanks to the page’s cat slug $parent_cat = get_category_by_slug( $cat[1] ); $cats_args … Read more
Add custom WP_Query after the first 3 posts
Sorting is not working in WordPress WP_Query
Try to set 3-rd parametr for wp_list_pluck function, as i see if it’s not set then there’s happaning an unnessesery, for you, loop. Try to set it to true or some, not existing in Object, key. Hope it helps.