Skip to content

Instantly share code, notes, and snippets.

@kachi
Created April 3, 2012 09:59
Show Gist options
  • Select an option

  • Save kachi/2290774 to your computer and use it in GitHub Desktop.

Select an option

Save kachi/2290774 to your computer and use it in GitHub Desktop.
<?php
$related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5, 'post__not_in' => array($post->ID) ) );
if( $related ) foreach( $related as $post ) {
setup_postdata($post); ?>
<ul>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
</ul>
<?php }
wp_reset_postdata(); ?>
/*抜粋などを含めることも可能*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment