• Hello –

    My objective is to display the SINGLE, most recent blog post on my front page while displaying all entries on a dedicated “Blog” page.

    I have attempted to copy single post.php from my theme into my “Home” page using the exec php plugin. I am using a static front page with my “blog page” separate.

    To specify a single entry in the php script entered, I added the following query above The Loop.

    ‘<?php
    get_header();
    query_posts(‘posts_per_page=1’);
    ?>’

    The front page now displays the most recent SINGLE entry in single post format which is my preference.

    The PROBLEM is that the content and title of the entry appear in duplicate at the bottom of the page without formatting. I can’t find the php problem to eliminate this redundancy. So close!!!

    You can view my issue at my site .

    I am not a technology professional and I would truly appreciate any helpful feedback in troubleshooting this last hitch in my new site!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter albert-james-cook

    (@albert-james-cook)

    see http://www.albertjamescook.com to view the error.

    I’m not sure why you’d be using exec-php for this. I’ve never used that plugin but it claims to ‘Executes PHP code in the excerpt and the content portion of your posts and pages‘ which suggests to me that you might be getting a kind of loop-within-a-loop effect. I think maybe the exec-php code runs through the loop because of the code you’ve copied, but the Page itself also has a loop which then executes (or partially executes).

    I think you might be better off creating a new page template and copying the code directly into that. For example, copy and save (in your theme directory) single post.php as something like myhomepage.php. Then edit your Home page (in the WP page editor) to use myhomepage.php as its template.

    But, I hasten to add, I’m not sure why what you’ve done works at all. The loop for a page should contain the data for that page only, not the data for any of the other posts on the site. But you are executing some extra code so there must be something in the code you copied that is creating a second DB query– at least that is all I can think of to explain it. I add this last part because I don’t if this ‘second DB query’ effect will still work if you do what I suggest.

    Anyway, maybe someone cleverer than I can do better.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Glitch in Attempting to Display a Single Post on Front/Home Page.’ is closed to new replies.