Forums

Home page show single post, i.e. single.php (4 posts)

  1. spiritbased
    Member
    Posted 1 month ago #

    Hi all

    I've been scouring the forum to no avail. What I want to be able to do is default my home page to the latest post, as in the 'single.php' version, and for my navigation to go back and forth through these single posts. I don't need a list of posts anywhere, and I don't need categories etc., I want to keep things very basic.

    Any ideas?

  2. jleuze
    Member
    Posted 1 month ago #

    You should be able to easily do this by changing your settings. Just go to Settings/Reading, and for "Blog pages show at most", set it to 1.

    Then your homepage will should one post instead of the default ten. Just about any theme should have built in navigation that will allow you to navigate to older and newer posts, but you might want to tweak this in your index.php file.

  3. pajtai
    Member
    Posted 2 weeks ago #

    If you do this, how can you get the previous_post_link link to work... I can only get previous_posts_link to work (NOT previous_post_link) on index.php, even within the loop.

    In other words, instead of going from page to page if you navigate from index, you go to the next permalink right away.

  4. jleuze
    Member
    Posted 2 weeks ago #

    Are you using different template files for the blog pages with multiple and the pages with single posts?

    To use these next and previous links, you need to have to different templates, or use some kind of conditional statement, but separate files would be the simplest method.

    Some basic themes might use index.php as the template for both multiple and single post pages. You'll want more than that.

    You should be using a template file called single.php for your single posts. This can pretty much be a copy of index.php depending on your theme. But in this template file, you'll want to use previous_post_link and next_post_link.

    In your index.php file, you'll want to include the previous_posts_link and next_posts_link.

    This is basically how it should be set up most of the time. Those navigation links are always going to navigate on the same level i think. So from one page of posts to the next, or from one single post to the next. But it won't ever jump from a single post to a page of posts or the other way around without the user clicking a permalink to switch where they are at in that hierarchy, which is what it sounds like you want to do.

    The only way I could see that being possible is if you can somehow force the single.php file to be the homepage of your site. You might try doing research on that.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.