How to add in WP_Query to every 3 posts displayed? [duplicate]

This would work: <?php $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 8, ‘orderby’ => ‘date’, ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { $i=1; echo ‘<ul>’; while ( $loop->have_posts() ) : $loop->the_post(); //wc_get_template_part( ‘content’, ‘product’ ); ?> <li class=”col-md-3″> <div class=”gridproduto”> <a href=”https://wordpress.stackexchange.com/questions/266104/<?php the_permalink(); ?>”> <?php global $post, $product; ?> … Read more

Get posts by birthday

What you can do is create a meta field under a post and store birth date in that field. Now you need meta_query in you post to retrieve the current date posts. <?php $currentDate = current_time( ‘Y-m-d’ ); $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘birth_date’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ … Read more

Query 3 meta_key and orderby

The meta_query has to be an array of array to manage the relation between the meta queried. You can read more on the codex page about wp_query here In an other side, post_type, post_status, has nothing to do on your meta_query clause, they are already in the main arguments if the query.

WP Query works outside a function, not inside a function

functions return an output. you don’t want to just echo it out. try this as your function: function mycoolquery() { $custom_taxterms = wp_get_object_terms( $post->ID, ‘region’, array(‘fields’ => ‘ids’) ); // arguments $args = array( ‘post_type’ => ‘stay’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 25, // you may edit this number ‘orderby’ => ‘rand’, ‘tax_query’ => array( … Read more