WordPress.org

Ready to get started?Download WordPress

Forums

How to Insert Stuff Just Above First Post Content (14 posts)

  1. ccano
    Member
    Posted 7 years ago #

    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.

  2. moshu
    Member
    Posted 7 years ago #

    Yes. Just be more precise about "item" or "stuff".
    Anyway, put it before the Loop in the index.php file of the theme.

  3. ccano
    Member
    Posted 7 years ago #

    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.

  4. moshu
    Member
    Posted 7 years ago #

    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:
    http://www.tamba2.org.uk/wordpress/adsense/

  5. icco
    Member
    Posted 7 years ago #

    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()) { ?>
    <div>Blargh</div>
    <?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. http://wordpress.org/support/topic/123517?replies=6

  6. moshu
    Member
    Posted 7 years ago #

    There is no "firstpost" function in WP :)

  7. icco
    Member
    Posted 7 years ago #

    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

  8. ccano
    Member
    Posted 7 years ago #

    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.

  9. moshu
    Member
    Posted 7 years ago #

    just below the headline and subheadline,
    Don't use non-WP terminology... nobody understands what are you talking about.
    Posts have:
    title
    meta or postmeta (like date/time, category, author, comment-link)
    content
    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.

  10. ccano
    Member
    Posted 7 years ago #

    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.

  11. Root
    Member
    Posted 7 years ago #

    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. :)

  12. whooami
    Member
    Posted 7 years ago #

    ccano,

    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:

    http://you-get.onewish.org.uk/category/uncategorized/

  13. harknell
    Member
    Posted 7 years ago #

    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.

  14. ccano
    Member
    Posted 7 years ago #

    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 (http://you-get.onewish.org.uk/category/uncategorized/) 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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.