WordPress First Post Only On Frontpage

If you check out my theme, you would notice that only the first latest post of my blog is expanded and showed and the rest of the post follows with summary. Some people would just love to have this kind of theme as it’s more clean when viewed. Here is the hack on how i did it. It’s not the cleanest code and im pretty sure there are better ways to do it, but it just works. Editing should be done to index.php file.

Basically the concept is to create multiple loop with post limitations and offset. Open up index.php and follow this code. The code below is used to display only the 1st post of your blog and it’s up to you to design it.

[php]

[/php]

After the code we follow up with another loop where you can specify how the remaining posts are displayed. You can display the title and also the excerpt like how i have displayed on my site.

[php]

[/php]

From the above code, we can simply change a few variables.

[php]

[/php]

In the code above you could change the ’showpost’ section to the number of remaining post you want to show on the frontpage and the ‘offset’ is used to skip how many posts before displaying the list of posts.

If you are having problem to display your posts inside category or if you use index.php as your category template, then adding this code in index.php might help.

[php]

[/php]

Basically that is about it. You may adopt this code into your theme and it should work fine, i tested it on WordPress 2.1x without problem. Please take note that this code might not work with all themes and also might cause conflict with some themes and plugins.

[tags]wordpress, tutorial, plugin, first, post, frontpage, code, hack[/tags]


2 Comments »

  1. Ananth said

    Wow this is a cool code…. will try it on my blog.. shall let you know the outcome… thanks for sharing

  2. novinthen said

    Just the hack i needed for indianvibez.com :D …ill try it on my web. thanks a bunch

RSS feed for comments on this post · TrackBack URI

Leave a Comment