How to Create a Page that Displays Random Post Wordpress

randompost


How to Create a Page that Displays Random Post WordPress

First Create a child theme and activate or create a  page this have you ever been to a site and saw this Look nice.  They have a link top navigation  bar to something like stumbe!  or Read Random Articles, or some other creative text.  When you click on that link, it take you to page that display one random article or image category some else.  Each time you refresh, you are delivered with a new post. this page  fatel error is click solve it.

Article Create Custom Page template and simple paste this code:

   <?php
query_posts(array('orderby' => 'rand', 'showposts' => 1));
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<?php the_content(); ?>
<?php endwhile;
endif; ?>


Display Relative Date:

 Have you  Ever seen this post  and comments and wondered how did the blogger  manage to do this?
Actually it is pretty very easy.

download plugin wp-relative date

once you have downloaded and activated this plugin, look in your single.php page and your site index page (index.php) and page.php for this code:


<?php   the_date();  ?>


Replace it with:

<?php  relative_post_the_date(); ?>

How to Create a Page that Displays Random Post Wordpress Dev2Tricks 5 of 5
How to Create a Page that Displays Random Post WordPress First Create a child theme and activate or create a  page this have you ever...

Share this

Related Posts

Previous
Next Post »