Skip to content

Instantly share code, notes, and snippets.

@RAStacy
Created December 18, 2015 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RAStacy/eadfd99a6cce1b3f7a01 to your computer and use it in GitHub Desktop.
Save RAStacy/eadfd99a6cce1b3f7a01 to your computer and use it in GitHub Desktop.
Use with YARPP to display recent posts as an alternative to related posts
<?php
if (!is_page(766)) {
related_posts();
} else {
$args = array( 'numberposts' => 4 );
$recent_posts = wp_get_recent_posts($args); ?>
<h3>Recent Posts:</h3>
<div class="recent-posts">
<ul>
<?php foreach( $recent_posts as $recent ){
echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"].'</a> </li> ';
} ?>
</ul>
</div>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment