WordPress.org

Ready to get started?Download WordPress

Forums

Display Random Single Post As Static Homepage (2 posts)

  1. drewhowell21
    Member
    Posted 1 year ago #

    Hey guys,

    I recently began building a WordPress site that doesn't actually have a homepage. When visited, you are presented with a single, random post. I've done this using the following code on index.php.

    query_posts( 'posts_per_page=1&orderby=rand' );

    This works for displaying a random post when visiting the site, but isn't working well for SEO purposes. Instead of using the meta title and meta description for the single post, I get the general meta info (Site name and Site Description).

    What I'm looking for is a way to display the posts on the homepage using single.php so each post will have the correct meta info for the single post.

    I tried creating a custom page template using the same code as I did for index.php and setting it as my static homepage, but for some reason I can't get it to work. I have tried researching this issue, but haven't been able to find a solution.

    Does anyone have any suggestions on how to do this? I can provide more information if need be.

  2. noahjonah
    Member
    Posted 1 year ago #

    Copy index.php, then add the functionality you want from single.php

Topic Closed

This topic has been closed to new replies.

About this Topic