How can we help?

If you are looking for support for our PokaTheme, this is the place!

Home Forums PokaTheme support Related reviews

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17319
    Jenna Anderson
    Participant

    How can we exclude specific operators from related reviews section under the review?

    #17324
    admin
    Keymaster

    Hi Jenna,

    There is not such an option, but you can achieve what you want with the following code snippet.

    /**
     *
     *  Modify the Related Posts query to NOT show Reviews with IDs 11, 23, and 58.
     *
     */
    function pokatheme_pre_get_posts_636a2e5fe2215( $query ) {
    	if ( is_singular( array( 'affiliates' ) ) ) {
    		if ( 'affiliates' === $query->query['post_type'] ) {
    			if ( array_key_exists( 'post__not_in', $query->query ) ) {
    				if ( 1 === count( $query->query['post__not_in'] ) ) {
    					$reviews_to_exclude = '11,23,58';
    
    					$reviews_to_exclude_array = explode( ',', $reviews_to_exclude );
    					$post__not_in_default     = array( get_the_ID() );
    					$post__not_in             = array_merge( $post__not_in_default, $reviews_to_exclude_array );
    					$query->set( 'post__not_in', $post__not_in );
    				}
    			}
    		}
    	}
    }
    add_action( 'pre_get_posts', 'pokatheme_pre_get_posts_636a2e5fe2215' );
    

    You need to change only this line:

    $reviews_to_exclude = '11,23,58';

    For example, the above code would exclude 3 reviews: those with IDs 11, 23, and 58.

    You can add the above code to your child theme’s functions.php, or using a plugin like Code Snippets.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.