Skip Navigation

[Gelöst] Redirect a taxonomy to a static WordPress

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
I have placed a taxonomy link (for more than one author) in my Content Template using the wpv-post-taxonomy shortcode. Instead of linking to the term archive page, I would like to redirect to a static page.

Solution:
1. This needs to be done using custom shortcode. Please add the following code in your theme’s or child theme’s functions.php file:

function custom_post_taxonomy_fun( $atts ) {
     
    extract(shortcode_atts( array(
    'site_url'      => home_url(),
    'taxonomy_slug' => '',
    'taonomy_name' => '',
), $atts ));
     
    $content = '';
    if($taxonomy_slug != '' && $taonomy_name != '') {
        $tax_slug_array = explode(',', $taxonomy_slug);
        $tax_name_array = explode(',', $taonomy_name);
         
        for($i=0; $i < count($tax_slug_array); $i++) {
            if($i != 0)
                $content .= ', ';
            $content .= '<a href="'.$site_url.trim($tax_slug_array[$i]).'">'.$tax_name_array[$i].'</a>';        
        }
    }
     
    return $content;
}
add_shortcode( 'custom_post_taxonomy', 'custom_post_taxonomy_fun' );

2. Then use this shortcode in Content Template like this:

[custom_post_taxonomy taxonomy_slug="[wpv-post-taxonomy type='autor' format='slug']" taonomy_name="[wpv-post-taxonomy type='autor' format='name']" site_url="http://borrador.editorial-zech.es/"]
This support ticket is created vor 6 Jahre, 7 Monate. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 Antworten, has 2 Stimmen.

Last updated by Javier Félix Hernández Márquez vor 6 Jahre, 7 Monate.

Assisted by: Noman.

Author
Artikel
#566356

Hi,

I added the link as indicated in this support thread to link a taxonomy to a static page in WordPress:

https://toolset.com/forums/topic/redirect-a-taxonomy-to-a-static-wordpress-page/

Now I have a new question related to this topic. Everything works fine as long as a single author is shown, but if there are two or more authors at the same time then the link returns a 404 error. You can see an example at this URL:

hidden link

Instead all other links, when a single author is displayed, work perfectly. You can see an example at this URL:

hidden link

The code used is the following:

<a href="hidden link type='autor' format='slug']">[wpv-post-taxonomy type="autor" format="name"]</a>

I would like to solve the 404 error when multiple authors are displayed at the same time. Is there any way to link each author to their page?

Thank you very much in advance.

Best regards,

#566673

Noman
Supporter

Languages: Englisch (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting Toolset support. This needs to be done using custom shortcode.

Can you please provide temporary access (WP-Admin and FTP Login info) to your staging site, so that I can look into your setup and try to create shortcode.

Your next answer will be private which means only you and I have access to it.

=== Please backup your database and website ===

✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.

Thankyou

#566784

Noman
Supporter

Languages: Englisch (English )

Timezone: Asia/Karachi (GMT+05:00)

I have added this code in your theme’s functions.php file:


function custom_post_taxonomy_fun( $atts ) {
	
	extract(shortcode_atts( array(
	'site_url'		=> home_url(),
    'taxonomy_slug' => '',
    'taonomy_name' => '',
), $atts ));
	
	$content = '';
	if($taxonomy_slug != '' && $taonomy_name != '') {
		$tax_slug_array = explode(',', $taxonomy_slug);
		$tax_name_array = explode(',', $taonomy_name);
		
		for($i=0; $i < count($tax_slug_array); $i++) {
			if($i != 0)
				$content .= ', ';
			$content .= '<a href="'.$site_url.trim($tax_slug_array[$i]).'">'.$tax_name_array[$i].'</a>';		
		}
	}
	
	return $content;
}
add_shortcode( 'custom_post_taxonomy', 'custom_post_taxonomy_fun' );

Then used this shortcode in Content Template like this:

[custom_post_taxonomy taxonomy_slug="[wpv-post-taxonomy type='autor' format='slug']" taonomy_name="[wpv-post-taxonomy type='autor' format='name']" site_url="<em><u>hidden link</u></em>"]

Now its working fine, you can check here:
hidden link

Please let me know if its good now, thank you

#566870

Hi,

Yes, everything works perfectly now!

Thank you very much again. I am very happy with the attention received.

Best regards,

Das Forum „Types Community Support“ ist für neue Themen und Antworten geschlossen.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.