[Resuelto] Displaying view by taxonomies url in the archieve loop
This support ticket is created hace 6 años, 2 meses. 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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
There is a basic problem with using the wpv-taxonomy-title and similar shortcodes, in that the only context they work in is in taxonomy Views (i.e. a View which lists taxonomy terms and not posts).
We have an internal ticket to expand the scope so that they also work in taxonomy archives.
In the meantime you'll need a custom shortcode to return the term of the current taxonomy archive.
I have written a generic taxonomy shortcode which will work both outside of the loop and within the loop on the taxonomy archive pages, and depending on the attributes you provide you can output any of the taxonomy (slug), the term name, the term slug, the term id, the term description, the count of results, or you can also use it to output term meta for the current term by specifying the field.
Here's the code to register the shortcode:
<?php
/**
* Register shortcode to output current taxonomy
* for use on taxonomy archive page outside or inside loop
* att['output'] string taxonomy | name (default) | slug | term_id | description | count | field (requres att['field'])
* att['field'] string key
*/
add_shortcode('taxonomy', function ($atts = [], $content = null) {
// provide defaults
$atts = shortcode_atts(
array(
'output' => 'name',
'field' => '',
),
$atts
);
extract($atts);
$return = '';
global $wp_query;
$obj = $wp_query->get_queried_object();
if ($output != 'field') {
$return = $obj->$output;
} else {
if (isset($field)) {
$return = get_term_meta($obj->term_id, $field, true);
}
}
return $return;
});
And here are some examples of using it:
[taxonomy output='taxonomy'] -- outputs the taxonomy slug
[taxonomy] -- outputs the term name (default)
[taxonomy output='count'] -- outputs the count of results
[taxonomy output='field' field='wpcf-colour'] -- outputs a 'colour' taxonomy custom field
(You should be able to use it in wpv-conditional shortcodes after registering the custom shortcode at Toolset > Settings > Front-end Content.)
i've added the shortcode at both 'Third-party shortcode arguments' and also the
'Functions inside conditional evaluations ' but i dont get the results desired.
[taxonomy output='taxonony'] would be outputting the slug of the taxonomy (not of any taxonomy terms), so in my example above it would output "status".
Where exactly are you using the taxonomy shortcode?
I'm not sure if you still need help with this, it's related to the other threads where we have been discussing your archive pages, but I'll mark as awaiting feedback from you in any case.