I have the settings so only one post (which is by default the most recent) displays with index.php
my current working code
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
How could I change to code to display a random post from any category/date?
It just needs to be one post if that makes a difference.
many thanks
Place the following code in your theme functions.php file.
I’m assuming when you say index.php you mean your blogs home page. The index.php file in your theme can be used for many other areas of your website so making any alterations in that file might have undesired effects else where.
Combine the two codes above like this:
Try posting this code above your current code: