• Hi, Great plugin. I’ve noticed an issue for a while and thought you’d probably know the answer pretty quickly.
    I excluded a category in the Searching tab. But when I search using the frontend, posts from that category show up along with the other results. When I perform the admin search, the posts from the excluded category do not show up. I can’t figure out what the issue is. Other categories that I excluded using the same method are being excluded properly it seems.

    Here’s what my search php page has:

    <?php
    /*
    Template Name: Search Page
    */
    ?>
    
    <?php get_header(); ?>
    
    <?php echo do_shortcode('[et_pb_section global_module="9281"][/et_pb_section]'); ?>
    
    <div id="main-content">
    	<div class="container">
    		<div id="content-area" class="<?php extra_sidebar_class(); ?> clearfix">
    			<div class="et_pb_extra_column_main">
    				<?php if ( is_search() ) { ?>
    					<h1><?php printf( esc_html__( 'Search Results for: %s', 'extra' ), get_search_query() ); ?></h1>
    				<?php } else if ( is_archive() && have_posts() ) { ?>
    					<h1><?php the_archive_title(); ?></h1>
    				<?php } ?>
    
    				<?php if ( is_extra_tax_layout() ) { ?>
    					<?php extra_tax_layout(); ?>
    				<?php } else { ?>
    					<?php require locate_template( 'index-content.php' ); ?>
    				<?php } ?>
    			</div>
    			<?php get_sidebar(); ?>
    
    		</div> <!-- #content-area -->
    	</div> <!-- .container -->
    </div> <!-- #main-content -->
    
    <?php get_footer();

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    If admin search works and the front end doesn’t, I’d say that’s because your front end is not running Relevanssi. However, your search is definitely powered by Relevanssi.

    It’s possible something is overriding the category exclusion. If you have taxonomy parameters for the search, the taxonomy settings from the search settings page can be overridden.

    If you don’t want the category included in the searches ever, it’s best to just not index the posts in the category. That way they can never show up in the searches, no matter what the settings.

    You can add this to your theme functions.php:

    add_filter('relevanssi_do_not_index', 'rlv_exclude_cat', 10, 2);
    function rlv_exclude_cat($exclude, $post_id) {
        $excluded_categories = array( 'category_a', 'category_b' );
        if ( has_term( $excluded_categories, 'category', $post_id ) ) {
            $exclude = true;
        }
        return $exclude;
    }

    Just replace category_a and category_b with either the slugs or the ID numbers of the categories you want to exclude and then rebuild the index, and those posts should never come up in searches.

    Thread Starter spost

    (@spost)

    Hi Mikko,
    I was working on this today and have a few notes:

    I wanted to see if your comment was true:

    It’s possible something is overriding the category exclusion. If you have taxonomy parameters for the search, the taxonomy settings from the search settings page can be overridden.

    I saw this in the URL:
    https://socratespost.com/?s=test-optional+world&et_pb_searchform_submit=et_search_proccess&et_pb_search_cat=18%2C1&et_pb_include_posts=yes

    This part stood out: et_pb_search_cat=18%2C1

    When I delete the that part of the URL, it seems to go away. As you might imagine, I’m using a Divi theme, particularly Extra in this case. Do you have any further guidance on what I could track down next? I looked in my functions.php and search.php files but I cannot figure out how that portion of the URL is populated nor do I know how to figure out what “search_cat” corresponds to that value.

    Thank you!

    • This reply was modified 3 years, 8 months ago by spost.
    • This reply was modified 3 years, 8 months ago by spost.
    Plugin Author Mikko Saari

    (@msaari)

    18%2C1 is 18,1, so it’s categories 18 and 1. 18 doesn’t seem to match anything public on your site and 1 is uncategorized.

    That value comes from your search form, which has this:

    <input type="hidden" name="et_pb_search_cat" value="18,1">

    and that is coming from the settings of your search form. So go take a closer look at the search form in the Divi editor.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Excluded categories showing’ is closed to new replies.