How to Create a Default Fixed Custom Posts layout for text and images

If you want many posts to be displayed differently than the rest you can add to them a specific category or a tag and have a conditional rule in your single.php file:

if ( have_posts() ) {
    while ( have_posts() ) { the_post();
        if ( in_category('houses') ) {

            get_template_part( 'single', 'house' );

        } else {
            get_template_part( 'single', 'post' );
        }
    }
} else {
    // No posts
}

For every post in category houses template from single-house.php file will be used and for all other posts single-post.php will be used.


If you want one post to have a different layout you should use a page instead. Posts are content entries listed in reverse chronological order, pages are meant to be static content type i.e. “About page”, you can learn more about that difference here.

Using a unique layout for a page is easy, you need to create a new page template and choose it for desired page. To create a post template you just need to place:

<?php /* Template Name: Example Template */ ?>

at the top of a new file and add all the necessary code below. For more information about page templates go here.


To learn more on with template file will be used read more about template hierarchy.