1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to remove this from wordpress website ?

Discussion in 'Content Management' started by lowriderzzz, Oct 27, 2017.

  1. #1
    Hi there!

    Ok I want this question to be understood properly.
    SEMrush
    I have a WordPress blog with lots of content in the form of articles published as posts. I have few pages as well. Yet I want some of the pages not to appear on the WordPress site when a search for relevant word is being performed.

    For instance I have articles with the topic of XYZ, and when a keyword of that topic is being placed in the search filed of the website itself (not google) , the results sometimes show a page that I would want to be displayed (like a thank you page for instance).

    So what can I do so certain pages don't appear when people write related term in the search field.

    * I've set Google to not index them, but that is not what I'm asking.

    Thank you!
     
    lowriderzzz, Oct 27, 2017 IP
    SEMrush
  2. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,641
    Likes Received:
    401
    Best Answers:
    21
    Trophy Points:
    295
  3. bluebelt91

    bluebelt91 Active Member

    Messages:
    878
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #3
    You can either use above plugin or put below code in Wordpress theme's Function.php:

    function jp_search_filter( $query ) {
    if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
    $query->set( 'post__not_in', array( 20 ) );
    }
    }
    add_action( 'pre_get_posts', 'jp_search_filter' );

    In the above example page id 20 will be excluded from search
     
    bluebelt91, Nov 22, 2017 IP