Forums

Adding elements to my blog page when there is more than one post (5 posts)

  1. nathanbunn
    Member
    Posted 1 year ago #

    I want to have my blog page recognize that there is more than one post. When it recognizes that there is more than one post on my page, I want it to insert a <div> in between them. Pages that have just one post will not have a <div> after the post. The <div> will be stylized using CSS and will act like a separating bar. How do I do that using WordPress? Is there something that can pick out if there are multiple posts?

  2. Chip Bennett
    Member
    Posted 1 year ago #

    What Theme are you using?

  3. nathanbunn
    Member
    Posted 1 year ago #

    I'm making my own. I downloaded a starter theme from http://wpcandy.com/made/the-wordpress-starter-theme-project (I haven't touched themes in a long time and I need to understand the structure fully to really make my own). I've modified it by adding new elements in but I have kept the core intact.

  4. Chip Bennett
    Member
    Posted 1 year ago #

    Ah, ok, then.

    Next question: what template files have you modified, if any?

    WordPress, by defualt, recognizes if more than one post is being displayed. Multiple posts are displayed in an "index" page, and single posts are displayed in a "single" page. The Template Hierarchy dictates which template file is used in each view.

    More than likely, you will need to modify the markup inside the Loop, in your index.php template file (or, alterately, the loop.php template file, if it exists).

  5. nathanbunn
    Member
    Posted 1 year ago #

    Mainly header.php and footer.php :P The most I've done to index.php and single.php is add a date icon.

    Here is the entire code, in between the get_header and get_footer functions:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    for any other page (including index.php, if I have 11 posts and 10 are displayed on my front page) that contains one blog post.

Topic Closed

This topic has been closed to new replies.

About this Topic