Hello,
I have a postype "membre" for which I'm using the standard WordPress taxonomy (category).
I need to retrieve the list of taxonomies that are related to a specific post.
I have already created a Views that list the taxonomies, but I can only list slug, name or url of taxonomies. I have not found the way to return only the ID of the taxonomies.
Can you help on this
Thanks
Pat
I have already created a Views that list the taxonomies, but I can only list slug, name or url of taxonomies.
Hi, you can't display the term IDs using a wpv-post-taxonomy shortcode, but you should be able to use the [wpv-taxonomy-id] shortcode in a View of terms. Is the wpv-taxonomy-id shortcode not working correctly inside a View of terms? If not, please copy + paste the code from your Loop Editor here for me to review.
Hi Christian,
Well, the issue I'm facing is a little more complex.
First, I have a user form to subscribe to the site. When the user subscribes, this form creates the user meta, but also, create (with a cred_save_data) a post (postype "membre") in order to have a post that replicates all user info (this is to manage easily the relation between a user and the post taxonomy. For info, this post taxonomy is the standard WordPress taxonomy (that I'm using to define the sports that a user likes.) and is also used for other postypes in the site).
Now, I have a user page where I want to list all sports that he likes. For this, I need to make the following link :
- logged in user => post "membre" => taxonomy linked to this post => display the taxonomies thanks to a Views
Currently, I have defined the Views that display the taxonomies (no issue), and I have also a Views to define the post_id of the post "membre" linked to the logged in user. I just (?) need to retrieve the list of the taxonomies linked to this post "membre" in order to pass them a an argument to the Views that list the taxonomies (term = "id1, id6, ID17" for example)
Hope this clarify the need.
Regards
Pat
I just (?) need to retrieve the list of the taxonomies linked to this post "membre" in order to pass them a an argument to the Views that list the taxonomies (term = "id1, id6, ID17" for example)
There's nothing built-in to Toolset that will produce a list of term IDs like this, other than a View of terms. If you know the ID of the Membre post, you can use it to display the related terms in a nested View like this:
- Create a View of this taxonomy, filtered by term, set by the current post (see term-filter.png).
- In this View's loop, output whatever you want to display for each term, like the wpv-taxonomy-title or wpv-taxonomy-link shortcode.
- Create a View of the Membre post type, filtered by post ID, set by a shortcode attribute "ids" (see post-filter.png)
- In the Loop of this View, insert the taxonomy View you just created
- Insert the Membre View somewhere on the site using a shortcode, and add the correct Membre post ID to the "ids" shortcode attribute:
[wpv-view name="Your Membre View Name" ids="12345"]
Replace 12345 with the Membre post ID.
Or if you don't want to use Views, you could write a custom shortcode using the wp_get_object_terms API:
https://developer.wordpress.org/reference/functions/wp_get_object_terms/
https://developer.wordpress.org/reference/classes/wp_term_query/__construct/
Hi Christian,
That's perfect. Many thanks.
Pat