• Resolved E-Support

    (@xxlescort)


    Hi Mikko

    I have relevanssi premium, and ACF taxonomies. The indexing works great and these are also taken into account during the search. I wanted to use your code to direct to the taxonomies if a search term matches exactly. I took the following code in Wpcodebox :

    
    
    add_action( 'saved_term', function() {
        $redirects    = get_option( 'relevanssi_redirects', array() );
        $product_cats = get_categories( 'taxonomy=product_cat' );
    
        $existing_redirects = wp_list_pluck( $redirects, 'url' );
        foreach ( $product_cats as $cat ) {
            $url = get_category_link( $cat->term_id );
            if ( ! in_array( $url, $existing_redirects, true ) ) {
                $redirects[] = array(
                    'url'     => $url,
                    'query'   => $cat->name,
                    'partial' => false,
                    'hits'    => 0,
                );
            }
        }
    
        update_option( 'relevanssi_redirects', $redirects );
    } );
    
    
    

    Then I went into a taxonomy and re-saved it, as it says in your instructions. But it doesn’t happen, I enter the taxonomy as a search term and it doesn’t redirect. do you have any idea?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Automatic redirects to category with ACF taxonomy’ is closed to new replies.