Support » Fixing WordPress » How to Insert Stuff Just Above First Post Content

  • Hi all, I’m looking for a way to place an item just above the content of the first post on my home page.

    Any idea how to do this?

    Thanks in advance for your help.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Yes. Just be more precise about “item” or “stuff”.
    Anyway, put it before the Loop in the index.php file of the theme.

    Thanks, moshu. Sorry for being unclear. I need to place a CSS div “box” with text just below the headline and category/comment links… but above the actual CONTENT of my first post.

    Placing the div before the Loop places the box above the first post’s headline. Any idea how to get it below the headline and just above the first paragraph?

    Thanks again.

    Well, that’s much more compliacted.
    You will have to search for a php code that will do the post count to display it only in the first post… and to insert your code/whatever right before the_content – and below whatever is there (category, comments etc.)
    This example is for ads but it should be a good starting point:

    You would have to do some loop hackery. I can’t look it up right now, but i’ll see if i can find the right function to call. But no matter what, you will basically do something like the following:

    <?php if(firstpost()) { ?>
    <?php } ?>

    so I just need to remember / find what to put in that besides firstpost() and you should be set. Until I find something, this also explains how to setup a counter, which would work quite well.

    There is no “firstpost” function in WP 🙂

    Meh. I wrote one for one of my old themes, I was gonna try and find it. But a counter is probably the easiest way to do it. I updated my above post to reflect this

    Thanks for the link moshu, but the tamba2 page doesn’t address how to place it just below the headline and subheadline, if any, and above the first paragraph.

    Thanks for taking the time to help me out with this, people. I appreciate it.

    just below the headline and subheadline,
    Don’t use non-WP terminology… nobody understands what are you talking about.
    Posts have:
    meta or postmeta (like date/time, category, author, comment-link)
    meta (if not shonw above)

    All these are placed in the Loop.

    The guide I sent you to has all the infor you need. You insert your “stuff” wherever you need it in the loop.

    Moshu, if “content” is WP terminology, then why does no one understand what I am talking about, as you suggest? In my first post in this thread I said I wanted to know how to place an item “just above the content.”

    Thank you for the link, but it does not have all the information I need. It explains how to put an ad:

    • at the top of the whole page
    • at the bottom of your posts
    • under the first post and nowhere else
    • 1 ad after the first post and 2 after the second

    It does not say how to place a container div just above the content and below the headline and postmeta data of the first post on the index page.

    Have I been clear?

    Thanks for your help.

    Another poster who is not reading the answers given. What you are trying to do involves a degree of php hackery. There is no off the shelf solution. You need to write the php on the lines given by adding a counter as suggested. If you can’t manage it get a php programmer in. They charge about $100 USD an hour. 🙂





    the way you do that isnt really any different than in the examples that Moshu so kindly provided..

    1. you have to count the posts..

    2. having counted the posts, you put whatever you want to display where you want it in the loop.

    See this, for instance:

    Or, you could simply download my AWSOM News Announcement plugin, which places a news announcement box right above your posts area on your index page and allows you to put any content in it you want. It uses either the visual editor or the code editor to input your content, and the announcement area can be turned on or off to hide or display it–all from the admin area.

    Alright, we’re getting somewhere. I really appreciate your help, everyone. I’m sorry if I am not competent in PHP as some of you are.

    Whooami, the link you provided ( shows exactly what I want to accomplish (the pink box, specifically).

    Could someone kindly clarify how I “count the posts” exactly? I searched the forums and docs and couldn’t figure it out.

    Thanks again for helping me out. I’m sure this will prove helpful to other community members in the future as well.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to Insert Stuff Just Above First Post Content’ is closed to new replies.