First archive page with a few posts

This is my archive template — page-archive.php, which I am using as a template to display all my posts/recipes So if you’re using a Page (post of the page type) with a custom/specific Page Template, then you should create a secondary query and loop for retrieving and displaying your recipes/posts. But even with a default … Read more

Getting blog pagination to work on page set as front page

Yes, you’re correct that on the static front page, we use get_query_var(‘page’) to get the current page number. And actually, the issue in question (“the number 2 isn’t highlighted“) happened because you used get_query_var(‘paged’) (note the paged) with the current arg for paginate_links(), which means you’re passing the wrong number. ‘current’ => max( 1, get_query_var(‘paged’) … Read more

Add custom text automatically on each post

You can use a regular expression to sniff for it on the the_content filter. add_filter( ‘the_content’, ‘wpse403518_custom_text’ ); function wpse403518_custom_text( $content ) { $regex = ‘/^([^\.!?]+)([\.!?])(.*)$/’; $replace=”$1 2022$2$3″; $content = preg_replace( $regex, $replace, $content ); return $content; } The regex The $regex variable is a regular expression, and what it does, roughly, is this: ^ … Read more

Custom loop ordering not working

“sort_order” => “ASC”, “sort_column” => “post_name” These are not sorting parameters. Use order and orderby instead as specified in the official documentation: https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters

For each loop on every word in post

Are you sure you want to link every instance of each ingredient? As a user, I wouldn’t mind if the ingredient list above the recipe had all its ingredients linked, but if the following instructions continued linking every ingredient I’d find that to be a lot of links I could accidentally tap on and lose … Read more

How to conditionally add Custom Post Type to Front Page

I believe that if all your products have the custom meta field show_on_front_page with some containing ‘1’ and some containing ‘0’ or some such, AND your regular posts do not have that field, then something like below should work: //… $query->set(‘post_type’, array(‘post’, ‘product’)); //add this $meta_key = ‘show_on_front_page’; $query->set(‘meta_query’, array( ‘relation’ => ‘OR’, array( ‘key’ … Read more