Modify the main loop to display current month / year

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’)

How to fix pagination for custom loops?

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

Echo all category names, apart from one

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

Do I need to use The Loop on pages?

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.