How to use a specific category archive index as the site front page?

Create a file front-page.php with the following content: locate_template( ‘category-image-gallery.php’, TRUE, TRUE ); That’s all. For the theme’s functions.php If you want to restrict the front page content to posts from that category, filter the front page query: add_action( ‘pre_get_posts’, ‘wpse_74225_frontpage_categories’ ); function wpse_74225_frontpage_categories( $query ) { if ( $query->is_main_query() && is_front_page() ) { $query->set( … Read more

Is it possible to manipulate the list of page templates?

The workhorse is WP_Theme::get_page_templates() (wrapped by the helper function get_page_templates()). If you check out the source, you’ll see: /** * Filter list of page templates for a theme. * * @since 3.9.0 * @since 4.4.0 Converted to allow complete control over the `$page_templates` array. * * @param array $page_templates Array of page templates. Keys are … Read more

Template for specific post of custom post type

For the templates WordPress uses, please always refer to Template hierarchy scheme in the Codex. As you can see there, single-{$posttype}-{$slug}.php does not exist, there is only single-{$posttype}.php. To do what you want, have a look at the filter ‘single_template’: add_filter( ‘single_template’, function( $template ) { global $post; if ( $post->post_type === ‘event’ ) { … Read more

How to make child categories recognize parent’s template displays

Thanks to @Rarst for guiding me to the right direction. Using his direction I googled again and again and found a blog article of WerdsWords with an excellent bit of code snippet filtered to category_template as Rarst suggested me, and the good news is: it worked for my cause: function new_subcategory_hierarchy() { $category = get_queried_object(); … Read more

Overide get_template_part( ‘partials/post’, ‘sidebar’ ); with a plugin

TL;DR: Use a child theme instead 🙂 If we dig into the code for get_template_part(), there’s an action there – get_template_part_{$slug} – which we could hook into. Digging a bit further, get_template_part() calls locate_template(), which calls load_template(). Unfortunately, there’s nothing in either of these functions that seems to be pluggable, so we can’t hook in … Read more