Intro text and blog posts on the homepage of a wordpress blog

I’m currently redeveloping my website, and looking to use wordpress as the software solution to manage my content. Having been a bit slack with my “code” development the past few years I am not able to just bash out some sweet code. Additionally I failed to fully implement the older design fully with the blog. So I am starting a fresh, learning how to build a template based on my web vision. It’s a slow process, but one which will hopefully prove fruitful.
Anyway, one of the problems I had encountered was that I wanted BOTH intro text on my blog homepage, along with the recent posts of my blog. Now wordpress, right out of the box will allow users to switch between one or the other, but being a bit of a perfectionist, I wanted both!
Needless to say, my little php code experience actually came to the rescue, quite simply an IF ELSE statement did the job! I edited the index.php file, right before my pages/posts is called by adding the following code:
<?php if (current_page_item == is_front_page()) echo “TEXT GOES HERE”; ?>

To break the code down, I simply ask if the current page “current_page_item” is the homepage “is_front_page()” – and if this statement proves correct, to then add in the text of my choosing. Simple, nice and easy code. Probably been done 100 times before, but my googling was proving useless. Stage 2 will be to call a page from the blog into the “TEXT GOES HERE” command, and also to add it as a separate theme file.

Leave a Reply