WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Create function to call theme/templates depending on page

[Resolved] Create function to call theme/templates depending on page

  • I have created my own theme that allows one post to show per page. I can change this to show more posts per page in admin. I want to be able to set a new page as the homepage that displays previews of posts (say 5) and that uses a different theme/template/css. Am I write in thinking that to do this I would require a custom function in functions.php. Could anyone help me write it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You shouldn’t need to mess with functions.php because this all sounds like a CSS issue as far as giving the home page a different design.

    If you want a different styling of your home page, you can just wrap the entire page and use CSS to style things differently. Navigate to your Header and find <body>. Change that to:

    <?php
    if (!is_home())
    {
    echo "<body id=\"home\">";
    }
    else
    {
    echo "<body>";
    }
    ?>

    Now you can use CSS to style all elements on the home page differently than all elements elsewhere since everything on the home page can be called on by using #home.

    As far as displaying previews of 5 posts, it’s probably query_posts that you want to use:
    http://codex.wordpress.org/Template_Tags/query_posts

    Honestly, though, most themes are set up to display excerpts from the latest 5 posts.

    A link to your site would help out.

    That’s brilliant thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Create function to call theme/templates depending on page’ is closed to new replies.
Skip to toolbar