Skip Navigation

[Résolu] List custom tags belong to custom post

This support ticket is created Il y a 3 mois. 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.

This topic contains 5 réponses, has 2 voix.

Last updated by Christopher Amirian Il y a 2 mois et 3 semaines.

Assigned support staff: Christopher Amirian.

Auteur
Publications
#2450581
Screenshot 2022-09-04 at 11.04.06 PM.png

Dear Sir/Madam,

I have a custom post type and custom categories and tags, I refer to the function wp_get_post_tags() but it doesn't support the custom tags, how can I get the list of tags belong to the post if I have the post id?

Best regards,

Kelvin.

#2450807

Christopher Amirian
Supporter

Languages: Anglais (English )

Hi there,

Toolset uses standard WordPress taxonomies when you add them via the Toolset options. It should work with the normal WordPress functions, but just to let you know there is a shortcode that you can utilize to retrieve the list of taxonomies.

For more information:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153472

In the shortcode ITEM attribute you can provide your Post ID, for more information:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

Thanks.

#2450811

Christopher Amirian
Supporter

Languages: Anglais (English )

Also please check this ticket where the supporter suggested using the get_terms WordPress function:

https://toolset.com/forums/topic/how-to-get-all-children-terms-of-a-custom-taxonomy-term/

Get Terms reference:

https://developer.wordpress.org/reference/functions/get_terms/

#2455079
Screenshot 2022-09-12 at 12.06.38 PM.png

Dear Christopher,

Can I use the shortcode to get specific post's category?

My custom taxonomies is healthqa-tag, I want to do

echo do_shortcode('[wpv-post-taxonomy type="healthqa-tag" separator=", " format="link" show="name" order="asc"]');

but for specific post.

Best regards,

Kelvin

#2455089

Dear Christopher,

I finally fix my requirement but still need your help.

                        global $post; 
                        $post = get_post( $_REQUEST['p'], OBJECT );
                        setup_postdata( $post );
                        echo do_shortcode('[wpv-post-taxonomy type="healthqa-tag" separator=", " format="name" show="name" order="asc"]');
                        wp_reset_postdata();                        

I want to add custom style to each taxonomy, for example

<span class="mytags"> .... </span>
#2455539

Christopher Amirian
Supporter

Languages: Anglais (English )

Hi there,

Unfortunately, it is not possible to add HTML instead of the separator in the shortcode.

It is possible to do custom PHP coding for that which is outside of our support scope. I will try to describe what will be the steps but we will not be able to code it for you.

You can create a custom shortcode:

https://toolset.com/documentation/programmer-reference/adding-custom-code/how-to-create-a-custom-shortcode/

Which you can retrieve the tags using the wpv shortcode there.

Then you can split the comma separated list to a PHP array:

hidden link

After that you can add your HTML code to each member of the array and mis all in a string:

hidden link

Now you can echo that string which will contain the formatted list.

Then youc an use that custom shortcode in the View instead of the wpv shortcode.

Thanks.