Skip Navigation

[Gelöst] tax term field in archive page

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

Problem:
How to output the taxonomy term name or slug on a taxonomy archive page.

Solution:
Views doesn't have a shortcode for this (the context for the wpv-taxonomy- shortcodes are taxonomy Views and the wpv-post-taxonomy shortcode used on an archive will output the terms of the first post shown in the archive, not of the archive itself).

You can register a custom shortcode to display the taxonomy name (or slug, or various other fields), as described here: https://toolset.com/forums/topic/displaying-view-by-taxonomies-url-in-the-archieve-loop/#post-1121600

This support ticket is created vor 6 Jahren. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Dieses Thema enthält 17 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Akhil vor 6 Jahren.

Assistiert von: Nigel.

Author
Artikel
#1131773

Hi Nigel.

i have a term field for tax ,
i created views for that and it load fine in the category archive page [single category] but when it come to the main archive page the term is not picking the value ,

what could be the issue ?

i need the term raw value for styling . ive added the style in the loop editor template,

i think i need to load this into a loop. i did get the raw value if i use the code " [wpv-view name="tax-term-tax-color-code-view" cached="off"]" but i need the raw value of the output to use inside the styling .

Thanks,

#1131790

i ve added this snippets inside , i do get the raw value but the value has more strange spaces and commas.

#1131958

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

This is the same issue as in the other thread.

The context for the wpv-taxonomy-field shortcode is a View that queries taxonomies, in won't work anywhere else.

On your archive you can output the field value using the custom taxonomy shortcode I detailed in https://toolset.com/forums/topic/displaying-view-by-taxonomies-url-in-the-archieve-loop/#post-1121600

[taxonomy output='field' field='wpcf-colour']

would output the term field value of the colour field for the term of the current taxonomy archive.

#1131996

Hi nigel.

the only code that output the related color code is [types termmeta='tax-color-code'][/types] but the output is

#640066

can see the hude gaps there? im using this fn:

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
 
function prefix_clean_view_output( $out, $id ) {
if ( $id == '7802' ) { //Change this to your View ID
$start = strpos( $out, '<!-- wpv-loop-start -->' );
if ( 
$start !== false
&& strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
) {
$start = $start + strlen( '<!-- wpv-loop-start -->' );
$out = substr( $out , $start );
$end = strrpos( $out, '<!-- wpv-loop-end -->' );
$out = substr( $out, 0, $end );
}
}
return $out;

}

you can see it here , i added next to the category name :versteckter Link

but this has no issue : versteckter Link

#1132005

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Screenshot 2018-10-22 at 14.00.20.png

If you are trying to output a raw View without the usual wrappers, that option was recently added to Views and you no longer need such code.

Note the option to Disable the wrapper towards the end of the View (screenshot).

Remove all whitespace between the wpv-loop tags and include only exactly what you want to be output.

#1132010

Hi Nigel. Yes this was added before. pls let me know if could look at the site inside.
the same credentials are valid here. let me update that now.

i am guessing something more than this that creating the strange characters and line breaks , Thanks

#1132684

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Please remove the custom code and use the option for the raw output without the wrapping div.

If it still doesn't display correctly then let me know and I'll check on the site to see if I can see where the problem is coming from.

#1132771

Hi Nigel. Yes the custom code was deactivated here : versteckter Link

Thanks,

#1132805

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

I don't think I have credentials for this site, I went back through our recent tickets, but I think the credentials I have are for another site on your network.

Can I get credentials for this site, please?

#1132806

Hi Nigel the same credential works here too since its a staging site . Pls let me know if doesnt work and send the secure reply. thanks.

btw this page with 1 tag works. versteckter Link

but this page with more then 1 displays all the tags : versteckter Link

#1133358

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

I tried to log in to versteckter Link with the credentials I got from the other thread but they were rejected.

Let me set up a private reply to get updated credentials from you.

#1133460

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

You have a term custom field "tax color" which is available to the dir and XXXX Blog Category taxonomies (screenshot).

Some but not all of your XXXX Blog Categories have a value set for this term field (screenshot).

But the links you shared where it is/is not working are tag archives.

versteckter Link is the archive for the "keto" tag.

The tags do not have the tax color term field available to them, and—sure enough—editing the keto tag shows there is no associated tax color field.

In the Layout for the XXXX Blog tag archive you are trying to output the wpcf-rise-blog-tag custom field but I'm not sure there is any such thing.

And the discussion above about the clean output of a View seems to be a red herring, because you are not using a View on this archive page as far as I can tell.

#1133482

my goodness, my mistake , there seems to have some changes made and approach.

i can confirm the post# #1132806 is in the wrong thread., my apoligies for the confusion.

The purpose of the tax-color-code is to be able to use for styling purpose. i have since use tax_class instead .

the line '[taxonomy output='field' field='wpcf-tax-color-code']' was added here:
versteckter Link.

it suppose to output raw value so i can use it for styling purpose .

thanks,

#1133483

regarding the tag its same patterns,

the keto like is not a good example but this is:versteckter Link

as you can see i am expecting to see the tag:disease alone but the output is showing
Tag: XXX, YYYYY, disease, foot, hand, mouth , etc

the shortcode [taxonomy output='field' field='wpcf-xxxx-blog-tag] suppoose to give raw value as you mention but it doesnt.

appreciate if you could remove the attachment images and my branding name to , pls use XXXX instead, many thanks ! 🙂

#1133515

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

OK, so you just want to be able to output the tag name or slug (I'm not sure which you want).

So you just use

[taxonomy output="name"]  or [taxonomy output="slug"]

I updated the header where you have been testing this.

(I deleted the screenshots, the links we share are private to us except where I explicitly mark them as public, which I haven't.)