Query Function and Template Tags for WordPressHow to: Accompanying Posts with Thumbnails in WordPress after Plugins

Related Posts by Tags

Creating a Mini Plugin to Show Accompanying Posts via Functions.php

Related posts can be calmly displayed with plugins, but did you anytime admiration how you could affectation accompanying posts with a Thumbnail after application a Plugin? In this article, we will allotment two altered algorithm which you can use to accomplish accompanying posts with thumbnails and abstain application any plugin.

while( $my_query->have_posts() )
$my_query->the_post(); ?>How to: Accompanying Posts with Thumbnails in WordPress after Plugins

Note: We will advance the congenital WordPress Column Thumbnail Function. So it is best if you apparatus this.

global $post;
$tags = wp_get_post_tags($post->ID);
if ($tags)
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=>5, // Number of accompanying posts that will be shown.
'caller_get_posts'=>1
);
$my_query = new wp_query( $args );
if( $my_query->have_posts() )

  • Additional Sources:

    How to: Accompanying Posts with Thumbnails in WordPress after Plugins is a column from: WPBeginner which is not accustomed to be affected on added sites.

    WordPress has this amazing anatomy accepted as “Post Tags” which you can use. You can tag anniversary of your posts with assorted keywords. This algorithm would acquisition added posts with any one of the tag that the accepted column has and will account them.

    echo '

  • Article Source : How to: Accompanying Posts with Thumbnails in WordPress after Plugins

    How to: Related Posts with Thumbnails in WordPress without Plugins