Custom page in archive page for certain category

You could use template_include conditionally. add_filter( ‘template_include’, ‘wpsites_photo_page_template’, 99 ); function wpsites_photo_page_template( $template ) { if ( is_category(’33’) ) { $new_template = locate_template( array( ‘photo.php’ ) ); if ( ” != $new_template ) { return $new_template ; } } return $template; }

Get archives as array

If you look at wp_get_archives() you will notice that the link is generated by get_archives_link(). That function supplies a filter that will allow you to replace the parens. This is fairly crude but does work. function archive_link_wpse_183665($link) { $pat=”|\(([^)])\)</li>|”; // preg_match($pat,$link,$matches); // var_dump($matches); $link = preg_replace($pat,'[$1]’,$link); return $link; } add_filter( ‘get_archives_link’, ‘archive_link_wpse_183665’ );

How can I use archive-{post_type}.php theme template?

Custom post type archive page does not need “dumb” Page. In fact, there could be the culprit. You should try this: Remove /* Template Name: Staff */ from archive-staff_member.php (not needed) Remove “dumb” stuff Page (if created). There could be some permalink conflict. Go to Admin > Settings > Permalinks and re-save it (it will … Read more

How to count the number of archives there are

Notes: Currently you’re echo-ing the output of wp_get_archives(). In order to return it, we must set the echo input parameter to false. You’re assuming the output of wp_get_archives() is an array, but it’s a string. Workaround: Here’s one way, by counting the <li> instances, with the html format: $args = [ ‘parent’ => 0, ‘hide_empty’ … Read more

Need sql to remove tags from older posts

Well, think splitting the task in multiple pieces. First we need to get the post id’s which has the category with id 705 and then we’ll remove the tags from those posts. Now if we transform this idea in to SQL then the query will be- DELETE wp_term_relationships FROM wp_term_relationships INNER JOIN wp_term_taxonomy ON ( … Read more

How to use index.php as a template for archives?

I haven’t tested this but in your archive.php file in the child theme use the following command to output the index.php file contents. <?php get_template_part( ‘index’ ); ?> This way you can have all the code in your index.php file but use it elsewhere preventing the duplication. If you don’t want to create an archive.php … Read more

show ALL latest posts with archive.php on example.com/latest

All internal rules must point to index.php. This isn’t your theme’s index.php file, this is the main core WordPress bootstrap file. Rewrite rules set query vars, query vars get parsed into queries, those queries have template files associated with them depending on type. Internal rewrite rules never point directly to theme files. If you want … Read more