Show all posts using the template page and the loop?
Show all posts using the template page and the loop?
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
It seems like you need to actually prevent two specific VIDEOS from displaying on the same screen (not preventing videos from the same CLIENT twice), but if I’m wrong you can still adapt this. The idea is to push each VIDEOS identifier (name, id, whatever) to an array as you output it, checking each item … 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
the_category echos content. You will not be able to use string manipulation. No strings are returned that you could manipulate. They are just echoed immediately. You could completely filter out a particular category, which seems to be an option, with this: function cat_filter_wpse_137596($categories) { foreach ($categories as $k => $c) { if (‘uncategorized’ === $c->slug) … 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.