Showing sticky posts with get_posts()
Showing sticky posts with get_posts()
Showing sticky posts with get_posts()
Show all posts using the template page and the loop?
have you tried adding a second $query->set() ? function loop_current_month( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘monthnum’, date(‘m’) ); $query->set( ‘year’, date(“Y”) ); } } add_action( ‘pre_get_posts’, ‘loop_current_month’ ); This should get all the posts from the current month or this year, note date(‘m’) and date(‘Y’)
The Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom query, you create … Read more
Shortcode in posts called by ajax is not working
Infinite Scroll on a loop?
you should use $wp_query to retrieve pages and posts because it’s the most efficient way and you can differentiate the loop with $current_post parameter which returns the index of the loop. It works like this <?php $args = array ( ‘posts_per_page’ => -1, //Showing all the pages ‘post_type’ => ‘page’, //Retrieving pages not posts. ‘post_parent’ … Read more
Sort results by groups of numbers and letters
According to the Theme Guide, full loops should be used, even on single templates. Full loops must be used in all templates. Just calling the_post() in a template like single.php or page.php is not enough. So yes, it’s a best practice to use full loops.
The problem seems to be in the Loop. Inside the Loop you are not incrementing the $the_query. You may change the code for the Loop as below: // The Loop if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); // Add this line to fix the issue smr_product_the_frontend_item(); } } else { // … Read more