• Resolved miocene22

    (@miocene22)


    OK I’ve been developing my own theme for my wordpress site.

    I would like to know how to put a bit of static content above my latest posts on the home page exactly as it appears at the moment here

    The problem with the way I’ve done it is I have just added a bit of static html to my theme’s index.php template file; which clearly is not a good way of doing things.

    What’s the best way of achieving this? Thanks for any help…

Viewing 7 replies - 1 through 7 (of 7 total)
  • The problem with the way I’ve done it is I have just added a bit of static html to my theme’s index.php template file; which clearly is not a good way of doing things.

    Why not? If this really is a static piece of code and you see yourself changing the text only very infrequently, there is nothing wrong with hard-coding it. If you want to change the text frequently this probably isn’t the way to go. Maybe you want to look into the sticky posts feature, for example.

    i don`t see any problems in adding static html. i do it all the time.

    If you wanted static content only on the home page, then a conditional statement in the header would be sufficient.

    Or if in all pages, the header is still suited, minus the conditional.

    You could always place an include in whichever file (header/index/whatever), then update that included file as you see fit, if you decide no-static content, then clear the file out, if you want something back, place some new content in the file…

    Is there something else you had in mind?

    Thread Starter miocene22

    (@miocene22)

    what happens if I try to go to a page that my theme doesn’t have a template file for? WordPress will revert to the index.php template and I’ll end up with the static content on a page that isn’t the home page.

    What would a conditional statement look like to solve this problem?

    <?php if(is_home()) { ?>YOUR HTML<?php } ?>

    Or depending on your setup you may need to use..

    <?php if(is_front_page()) { ?>YOUR HTML<?php } ?>

    Or maybe even both..

    <?php if(is_home() || is_front_page()) { ?>YOUR HTML<?php } ?>

    Thread Starter miocene22

    (@miocene22)

    Great, thanks for the help

    If you were to manage via the backend this content block above the posts on the homepage, how would you go about it?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘static bit of content on front page’ is closed to new replies.