Skip Navigation

[Résolu] Redirect a taxonomy to a static WordPress in translating with WPML…

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.
This support ticket is created Il y a 7 années et 2 mois. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

Marqué : ,

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par Javier Félix Hernández Márquez Il y a 7 années et 2 mois.

Assisté par: Luo Yang.

Auteur
Publications
#571435

Hello again,

As shown in this support thread:

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

After adding the following code in the 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 .= ''.$tax_name_array[$i].'';
}
}

return $content;
}
add_shortcode( 'custom_post_taxonomy', 'custom_post_taxonomy_fun' );

and the following shortcode in the content template:
[custom_post_taxonomy taxonomy_slug="[wpv-post-taxonomy type='autor' format='slug']" taonomy_name="[wpv-post-taxonomy type='autor' format='name']" site_url="lien caché"]

everything works perfect in the Spanish version.

But now that I'm starting to translate the web into the German language with the WPML plugin, I have a new question related to this topic.

How can I make this code fragment work in the translated version of the web with WPML and not show a 404 error when clicking on the name of the author?

In the following link an example of the Spanish version working perfectly (when you click on the name of the author it redirects to its corresponding page):
lien caché

In this other link an example of the error 404 that is shown when clicking the name of the author (version translated into German):
lien caché

As a reference we take Alexander von Humboldt as an author already translated:
lien caché
lien caché

Thank you very much in advance!

Best regards,

#571657

Dear Javier,

It is a custom codes question, please provide a test site with same problem, and fill below private detail box with login details and ftp access, also point out the problem page URL, and where I can edit your PHP codes, In need a live website to test and debug this problem, thanks

#571961

Thanks for the details, I am checking it in your website, will feedback if there is anything found

#572045

Here is what I found:
1) URL lien caché
It is a post of custom post type "autoren" , it isn't a wordpress user archive page, and there isn't any relationship between the taxonomy "autor" and custom post type "autoren",

2) the custom shortcode you mentioned above won't be able to work in multiple language environment, since the term slug and site URL are different in Spanish language and German lanugage.
https://toolset.com/forums/topic/redirect-a-taxonomy-to-a-static-wordpress-in-translating-with-wpml/#post-571435

3) in your case, it does not need custom codes. I suggest you try these:
a) Create a URL term field "autores-url" in taxonomy "autor":
lien caché

b) Edit each term of taxonomy "autor" in both language, setup the value of field "autores-url"
For example, author "Alexander von Humboldt"
lien caché
in the field "autores URL", fill the URL: lien caché

c) Create a taxonomy view,
lien caché
query term of taxonomy "autor"
filter with:
Taxonomy is set by the page where this View is inserted

and display the "autores URL" in the view loop, like this:

<a href="[types termmeta='autores-url' output='raw'][/types]">[wpv-taxonomy-title]</a>

Then put use above taxonomy view to replace the [custom_post_taxonomy_fun]
lien caché

      <hr />
      [wpv-view name="redirect-a-taxonomy-to-a-static-wordpress-in-translating-with-wpml"]
      <hr />

See the result here:
lien caché

#572491

Hi,

Now it works fine. Thank you very much again!

Best regards,

Le forum ‘Types Community Support’ est fermé à de nouveaux sujets et réponses.