• Resolved teeboy4real

    (@teeboy4real)


    Hello,

    Please I am using your snippet at https://github.com/simpliko/wpadverts-snippets/tree/master/related-ads
    How can I hide the related ads on advert details page when there is no related ad showing. This text shows when there is no related ad (There are no ads matching your search criteria.) but I don’t want this to show at all when there is no related ad based on keyword.
    The related ads should only display when the ad has related keywords.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    hmm to show the related ads only if there is at least one related Ad you would need to edit the related ads snippet and at the beginning of the function related_ads_tpl_single_bottom (even before add add_filter() call) add

    
    $post = get_post( $post_id );
    $args = array(
      'post_type' => 'advert', 
      'post_status' => 'publish',
      'posts_per_page' => 5, 
      'paged' => 0,
      's' => $post->post_title,
      'post__not_in' => array( $post->ID )
    );
    $the_query = new WP_Query( $args );
    if( $the_query->found_posts === 0 ) {
      return;
    } 
    
    Thread Starter teeboy4real

    (@teeboy4real)

    Awesome thanks a lot it worked perfectly

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide related ads with no related keywords’ is closed to new replies.