2 weeks ago from meta query meta value
2 weeks ago from meta query meta value
2 weeks ago from meta query meta value
New WP_Query loop in admin causes problems
UPDATE! OK!!! Woooohooo! Found out what it was.. I should have been calling if have posts before the call for $tax->name; Here is my final, and working code! 🙂 <?php /**********************************************/ // CUSTOM WINE MENU SHORTCODE /**********************************************/ add_shortcode( ‘wine_list_per_cat’, ‘wine_list_per_cat’ ); function wine_list_per_cat($atts){ global $woocommerce_loop; extract(shortcode_atts(array( ‘cat’ => ”, // list of categories in the … Read more
The first way, using the pre_get_posts action will modify the main query before the page loads. The second way will create a new query. It is much better to alter the main query than to create a new query.
Configuring a meta query with multiple post types that have the same relationship on a single page
The loop doesn’t really contain anything. It does include methods in order to easily output your data such as the_title(), this is done when calling the_post() Then, within the loop you’ll be able to use get_the_ID() and get_post_meta() to get your custom fields (including ACF ones). So if you have retrieved your desired posts from … Read more
Custom post type archive pagination query issue
This question is opinion based, so the answer can be opinion based too. I assume that, if you need to paginate the posts, you are building a page template to look like an archive page. In this case I totally recommend to use an archive page and to use pre_get_posts action hook for filter the … Read more
Run first query las 10 posts, than use array_rand PHP function on posts array: $args = array( ‘posts_per_page’ => 10, ‘post__not_in’ =>array( $post->ID ), ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’ ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { if ( $query->post_count > 4 ) { $query->posts = array_rand( $query->posts, 4 ); … Read more
Pagination on static Posts page