Question

enter image description hereI'm trying to set a template to our blog page which is set as Posts page in WP Admin. The theme is Twenty Fifteen. The issue is that the option Template selector which appears for all other pages under Page attribute menu doesn't appear only on pages set as Posts page. Is this an error tied to this version or theme? There are multiple templates used in this website, but none seems to appear for this page.

Was it helpful?

Solution

You cannot set a custom template for the latest posts page. This setting is ignored for it. The template that is used for this page is determined by the Template Hierarchy.

WordPress template hierarchy

So if you start at the left for Blog Posts Index Page you'll see that it uses home.php for its template, if it exists, otherwise it uses index.php.

But if your homepage is set to show the latest posts then front-page.php will be used if that exists.

PS: You're running a 2 year old version of WordPress, and should update as soon as possible.

OTHER TIPS

If you want to use template file, you need to write functions.php.

Hook is theme_page_templates.
like this


 * @param array $post_templates Array of page templates. Keys are filenames, values are translated names.
 * @return array Filtered array of page templates.
 */
function makewp_exclude_page_templates($post_templates)
{
  if (version_compare($GLOBALS['wp_version'], '4.7', '<')) {
    unset($post_templates['templates/my-full-width-post-template.php']);
  }
  return $post_templates['page-templates/blog.php'];
}

add_filter('theme_page_templates', 'makewp_exclude_page_templates');
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top