WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Create function to call theme/templates depending on page (3 posts)

  1. Anonymous
    Unregistered
    Posted 5 years ago #

    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.

  2. tsguitar
    Member
    Posted 5 years ago #

    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.

  3. Anonymous
    Unregistered
    Posted 5 years ago #

    That's brilliant thanks a lot!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.