Saltar navegación

[Resuelto] redirecting taxonomy links

This support ticket is created 2 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

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 -

Zona horaria del colaborador: Asia/Kolkata (GMT+05:30)

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por Minesh 2 years, 3 months ago.

Asistido por: Minesh.

Autor
Mensajes
#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 (enlace oculto) to (enlace oculto)

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

#2683356

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: 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:
- enlace oculto

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
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

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

<em><u>enlace oculto</u></em>

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:

enlace oculto

#2683630

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: 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 enlace oculto.

};

};

};

It should go from this page: enlace oculto

to this page: enlace oculto

right now I am getting: enlace oculto

#2683765

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: 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 enlace oculto.

};

};

};

Hope this is useful