amritanshu
amritanshu

Reputation: 61

Display the similar posts to a custom post

I have a custom post type 'events'. On 'single-events.php ' i want to display the similar posts related to this . I am using the following code but the problem is it is also displaying the current post. How do i get rid of current post, please help me out.

 <?php
                   $args = array( 'post_type'=>'events',
                  'tax_query' => array(

                    array(
                      'taxonomy' => 'Event type',
                      'field' => 'slug',
                      'terms' => $type,
                    )
                  )
                );
                $postslist = get_posts( $args );


              ?>

Upvotes: 0

Views: 71

Answers (1)

radscheit
radscheit

Reputation: 352

You could try to make a ifcondition into your loop which asks for the id of the post not to be the same of the current post.

Upvotes: 1

Related Questions