January 2, 2011 at 6:40 am #30492
I have a WordPress Homepage and a Blog Page. Somehow I would like to have the latest/most recent blog post to be on the homepage. I tried googling and inserting a few php codes but none seemed to work.
Anyone know of a quick tutorial or solution to this?January 2, 2011 at 10:57 am #67813
You could just use query_posts within that if statement at the start of your loop, or you could use a custom loop for index.php and use it in there:
< ? php query_posts('posts_per_page=1'); ?>January 2, 2011 at 10:58 am #67814
By the way I really recommend chris’s book diggin into wordpress, it explains this in there. The PDF copy is only $27 and well worth it if you’re considering using wordpress on a regular basis.January 2, 2011 at 11:22 am #67824
I always prefer the second option, someone else might be able to advise you better on a way to achieve it using the first way though. One option could be to pull the latest post using RSS, although there may be a better way.January 2, 2011 at 12:11 pm #67835
ahh, what you need to do is the query posts as Johnny suggested and create a separate page for your homepage and your blog, page-slug.php, slug being the title of the page, created in wp admin, then have your index be a basic loop, with links to header and footers as index.php is mainly a fallback if there isn’t any other pages for them to use, so if there isn’t a single.php, or a page.php, they fall back to index.php. check out template hierarchy here:
http://codex.wordpress.org/Template_HierarchyJanuary 2, 2011 at 2:27 pm #67855
that works also^^
You must be logged in to reply to this topic.