Skip Navigation

[Resolved] 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 7 years, 2 months ago. 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)

This topic contains 4 replies, has 2 voices.

Last updated by Javier Félix Hernández Márquez 7 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#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="hidden link"]

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):
hidden link

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

As a reference we take Alexander von Humboldt as an author already translated:
hidden link
hidden link

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 hidden link
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":
hidden link

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

c) Create a taxonomy view,
hidden link
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]
hidden link

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

See the result here:
hidden link

#572491

Hi,

Now it works fine. Thank you very much again!

Best regards,

The forum ‘Types Community Support’ is closed to new topics and replies.