• Resolved yatgirl

    (@yatgirl)


    I am so sorry – I get one thing fixed and then another plugin causes issues.
    The Relevanssi v 4.09 search is working great now – but a page builder plugin update is now causing issues with category search result urls. I think there might be a way around it – but need your advice.

    I have a code snippet that allows html in category descriptions. As a side affect, when I use a search url within a category description – it shows the that category html description at the top of the page. For example:
    Search link within a category

    This was unexpected, but fine until the latest SiteOrigin page builder update 2.66. Luckily I just updated on my staging site, but what is now happening is my whole home page is showing above the category search result instead of the relevant category html description.

    I have asked for help in the SiteOrigin forum, but I am thinking one way around this would be to exclude the html category description from appearing on the search results page and I was hoping you might have a handy code snippet to do this or point me to where I might find a solution.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter yatgirl

    (@yatgirl)

    I have received an answer from SiteOrigin – this post here

    The is what they said :

    Hm. Okay, so the issue here appears to be that the search URLs are set to be on the index. This could be why our checks have failed and why this issue happens. Is it possible to change your Relevanssi settings to have the search be on a custom dedicated page like dogshoppe.net/search/?

    Regarding the category description, I can’t seem to see that at the moment (that’s likely due to the selections I tried) but chances are you can either hide that with CSS or there would be a setting to disable that in Relevanssi.

    Thread Starter yatgirl

    (@yatgirl)

    sorry forgot the link to the site origin post
    Siute origin post

    Plugin Author Mikko Saari

    (@msaari)

    That’s a bit of an odd answer, considering that every WordPress installation has the search “on the index”. That’s just how it works.

    The category description isn’t coming from Relevanssi. It’s your theme. What’s in your search results template?

    Thread Starter yatgirl

    (@yatgirl)

    I am hoping I am looking in the right place. I am using storefront with a boutique child theme. The only file I could see that looked like it might be correct is in the Storefront folder and is called search.php
    Below is the code

    <?php
    /**
     * The template for displaying search results pages.
     *
     * @package storefront
     */
    
    get_header(); ?>
    
    	<div id="primary" class="content-area">
    		<main id="main" class="site-main" role="main">
    
    		<?php if ( have_posts() ) : ?>
    
    			<header class="page-header">
    				<h1 class="page-title"><?php printf( esc_attr__( 'Search Results for: %s', 'storefront' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
    			</header><!-- .page-header -->
    
    			<?php get_template_part( 'loop' );
    
    		else :
    
    			get_template_part( 'content', 'none' );
    
    		endif; ?>
    
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    <?php
    do_action( 'storefront_sidebar' );
    get_footer();
    Plugin Author Mikko Saari

    (@msaari)

    Nothing unusual there. I’m sorry, but this falls too deep in the SiteOrigin territory, I have no idea what’s going on here.

    Thread Starter yatgirl

    (@yatgirl)

    Hi Mikko

    Thanks for taking a look –
    The category description only appears when a category is listed in the search url – it doesnt happen with a regular search.
    – I deactivated SiteOrigin and the behaviour still exists. So its not SiteOrigin.
    – I deactivated the code snippet you provided for being able to search within a category and the behaviour still exists – as long as the category is listed in the search link url- so its not the code snippets.
    – You advise that it isnt my theme, so I dont know what makes the category description appear at the top of the search results when limiting a search within a category.

    I have thought of 2 possible workarounds.

    WORKAROUND 1. LIMIT SEARCH TO A PRODUCT TAG
    I only have 10 important links that I need to restrict to a category. Perhaps instead, I can add product tags for those products and then restrict the search url link to a product tag?
    ex: (my url) s=Collie+Flags&product_tag=collie-flag&post_type=product

    I have adjusted the code snippet you gave me to allow search in a specific category and amended it to instead allow searches within a product tag. Since I am not familiar with code – can you please look at the code snippet I have created below and advise if this will work properly and not cause issues if I use the below and also keep the original code snippet activated to allow searches within a category?

    add_filter( 'relevanssi_modify_wp_query', 'rlv_include_product_tag' );
    function rlv_include_product_tag ( $query ) {
    	if ( isset( $query->query_vars['product_tag'] ) ) {
    		$query->query_vars['tax_query'][] = array(
    			'taxonomy' => 'product_tag',
    			'field' => 'slug',
    			'terms' => $query->query_vars['product_tag'],
    			'include_children' => false,
    		);
    	}
    	return $query;
    }

    WORKAROUND 2. CREATE PRODUCT TAGS AND JUST LINK TO THE PRODUCT TAG PAGE
    alternatively, even simpler – I could create product tags to those products and just link to that tag PAGE… (my url) product-tag/collie-flag/

    Since you are the search expert and know the possible pitfalls of either scenario above, if you could give me your advice on what you think is the best solution. Then I dont have to link to a search in a category at all and will avoid the messy situation that I cant figure out ??

    Plugin Author Mikko Saari

    (@msaari)

    The trigger here seems to be the product_tag parameter in the search. When SiteOrigin sees that, it probably assumes you’re on a product tag archive page (it should also check if there’s a s parameter and if there is, back off).

    But yeah, if what you want is product tag archives, then I would suggest doing that, as showing a simple tag archive is much easier on your server than doing a Relevanssi search.

    Thread Starter yatgirl

    (@yatgirl)

    Perfect, thats what I will do then, just add product tags to those products and then link to a tag archive – its a simple solution that works within wordpress woocommerce and will only take a couple of hours to set up and then it should work fine forever (fingers crossed ??

    Thank you very much for your input and advice !

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘search wthin a category – includes header’ is closed to new replies.