Support » Fixing WordPress » How to make wordpress fall back on another template instead of single.php

  • Resolved faeronsayn

    (@faeronsayn)


    So I have a customized single.php file that I don’t want wordpress to fall back on when it can’t find a custom post type template.

    So basically, how can I define another template for wordpress to fall back on instead of the usual single.php?

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’m not sure that I understand your question.

    Although if a post does not have a custom template then it will need to use single.php. And as you have already done, customise single.php to look the way you want it when there is not custom post template.

    How can I make wordpress use another template as it’s default one to fall back on instead of single.php.

    I don’t want wordpress to use single.php when it can’t find a custom template for the custom post type. I want wordpress to use another template, where can I define this?

    Is this a possibility or no?

    You can add a filter to the “single_template” filter hook and change which template is used there based on whatever you like.

    Thanks Samuel. I was going to look this up

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

    Please review the Template Hierarchy for single post pages.

    If you don’t want your custom post type to fall back on single.php for the single post view, you will need to define single-{posttype}.php, where {posttype} is the slug of the registered custom post type.

    If you want to have a general fallback for single post pages, and customize the single post page for blog posts, you could put that cusotmization in single-post.php, since post is the post-type slug for blog posts.

    Thanks, this seems to have resolved my issue, I didn’t know you could actually use “single-post.php” I thought that the “single.php” was for posts. Anyway, that seems to have fixed the problem.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to make wordpress fall back on another template instead of single.php’ is closed to new replies.