Skip Navigation

[Resolved] Output different templates with one taxonomy

This thread is resolved. Here is a description of the problem and solution.

Problem:

Use filter hook wpv_filter_force_wordpress_archive in custom PHP codes.

Solution:

The client managed to find a solution using views/templates and conditionals, so won't need the custom code.

Relevant Documentation:

This support ticket is created 3 years, 8 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
- 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 3 replies, has 2 voices.

Last updated by JorgeE7101 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1724527

Hello. This a following from a issue I raised a while ago, which you can see here:

https://toolset.com/forums/topic/output-different-templates-with-one-taxonomy/

In summary, the goal is to output slight different information according to the taxonomy applied (parent, child, etc).

It was solved, but now I am migrating the site to the Genesis framework and it no longer works.

The code that was working until now in functions.php was the following:

/**
* Code for adding a custom archive page for different sections.
*/

add_filter( 'wpv_filter_force_wordpress_archive', 'switch_tax_archive_by_level', 30, 2 );
function switch_tax_archive_by_level( $wpa_assigned, $wpa_loop ) {
$wpa_to_apply = $wpa_assigned;
$tax = get_queried_object() ? get_queried_object()->taxonomy : null;
if ($tax == 'viagens') {
$current_term_level = get_tax_level(get_queried_object()->term_id, get_queried_object()->taxonomy);
if ($current_term_level == 1) {
// show top-level archive
$wpa_to_apply = 1761;
} else if ($current_term_level == 2) {
// show mid-level archive
$wpa_to_apply = 1722;
} else {
// show third-level archive
$wpa_to_apply = 4129;
}
} elseif ( is_home() ) {
$wpa_to_apply = 1771;
}
return $wpa_to_apply;
}

Nothing has changed in terms of structure, either in Toolset or the website, so all taxonomy relations still apply.

Any help to fix it would be great.

Thank you in advance.

#1725405

Hello,

How do you migrate you website to Genesis framework?
How do you setup the taxonomy "viagens" archive page? You need make sure it is using Toolset WordPress Archive to render the archive page, see our document:
https://toolset.com/course-lesson/creating-a-custom-archive-page/

#1725453

Since it is a custom PHP codes + compatibility problem, please provide a full copy of your website in below private message box, , you can put the package files in your own google drive disk, share the link only, also point out the problem page URL and WordPress Archive URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1727953

Hi there.

Thanks for the reply. I've managed to find a solution using views/templates and conditionals, so I won't need the custom code.

Thanks.

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