Skip Navigation

[Resolved] redirecting taxonomy links

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 6 replies, has 2 voices.

Last updated by Minesh 1 year ago.

Assisted by: Minesh.

Author
Posts
#2683302

Ian

I am trying to redirect taxonomy links to a page. I could have done this with views but it does not work as soon as a post has more than one term.

For example I need to change (hidden link) to (hidden link)

So when you click the category link on this page: hidden link instead of the archive you go to this page pre filtered hidden link

#2683356

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As I understand - when user click on the "lamb-queen" link, you want the user to redirect back to the following page:
- hidden link

If this is correct - can you please share admin access details and let me check how you added the taxonomy link.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2683563

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What if you try to construct the link as given under:

<a href="/?_filter_vendors_category=[wpv-search-term param='_filter_vendors_category']">[wpv-post-taxonomy type="vendor-category" format="name"]</a>

More info:
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-214940

#2683624

Ian
multiple categoris.jpeg

This has the same problem if a post has more than one term.

You end up with this as a link:

Agricultural Produce, Meat Dairy & Eggs

#2683630

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share the whole flow from what page you start and to what link you want to click and what you want to see when there are multiple terms assigned to post.

Can you please share all those step by step information with URLs and let me see what we can do.

#2683638

Ian

OK I have something close but the term is not working

add_action( 'wp', 'wpso_71266569' ); //hook into wp's init action hook

if ( ! function_exists( 'wpso_71266569' ) ) {

function wpso_71266569() {

//Let's make sure we're on a taxonomy "vendor category" page:
//Either taxonomy-{taxonomy}.php or taxonomy-{taxonomy}-{term}.php.
if ( is_tax( 'vendor-category' ) ) {

$term = get_term( get_queried_object_id() ); //Retrieve the current term slug.

wp_redirect( '/vendors/?_filter_vendors_category=($term->slug)'); //eg: Redirect to hidden link.

};

};

};

It should go from this page: hidden link

to this page: hidden link

right now I am getting: hidden link

#2683765

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'm afraid that we are not allowed to debug such custom code and its beyond the scope of our support policy. If you need custom programming for your project, you're welcome to contact any of our certified partner:
- https://toolset.com/contractors/

However - here is few links that might help you to understand how you can add custom redirection:
- https://code.tutsplus.com/the-rewrite-api-the-basics--wp-25474a

I see the code you shared may be inspired using the following link but I do not see any votes to the solution shared:
- https://stackoverflow.com/questions/71266569/redirect-custom-taxonomy-terms-archive-to-page

I suggest you may check for any permalink or redirection plugin if any of such plugin offer you the solution you are looking for.

#2683849

Ian

I managed to figure this one out. I have made it less specific so that other users may find it useful. The intention is to redirect an archive link to a page that is filtered. This helps if you are using a faceted search tool.

/**
* Redirect term page to the corresponding custom slug page with query.
* *
* @since 1.0.0
*
* @param void
* @return void
*/
add_action( 'wp', 'efm_243612' ); //hook into wp's init action hook

if ( ! function_exists( 'efm_243612' ) ) {

function efm_243612() {

//Let's make sure we're on a taxonomy "my category" page:
if ( is_tax( 'my-category' ) ) {

$term = get_term( get_queried_object_id() ); //Retrieve the current term slug.

wp_safe_redirect( home_url('/pagename/?_filter_my_category='.( $term->slug ) ) ); //eg: Redirect to hidden link.

};

};

};

Hope this is useful