Skip Navigation

[Resolved] How can I use wpc-for-each for term meta fields

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

Problem:
I'm trying to use the wpc-for-each shortcode for a termeta.

Solution:
-Unfortunately, Views doesn't support this feature but it's a nice feature that we wish to add it to Views.

-We added this feature to our to-do list so that we can add it to our plugins if possible.

-FYI, implementing a feature in Toolset depends on many factors and we implement features depending on their priorities.

-You always can check the newly added features to Views from the changelog page: https://toolset.com/download/toolset-views/#changelog .

This support ticket is created 8 years 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 – 10:00 - - - - -
- - - - - - -

Supporter timezone: Africa/Cairo (GMT+02:00)

This topic contains 4 replies, has 3 voices.

Last updated by Mohammed 8 years ago.

Assisted by: Mohammed.

Author
Posts
#381823

Pat

Hello,
I'm trying to use the wpc-for-each shortcode for a termeta that way :

[wpv-for-each termmeta="images-secondaires-categorie"]
<div class="col-sm-4"><a href='[types termmeta="images-secondaires-categorie" raw="true"][/types]' data-rel="lightbox">[types termmeta="images-secondaires-categorie" size="thumbnail" align="center" resize="proportional" separator=" "][/types]</a></div>[/wpv-for-each]

The result here is that all occurences are inseted in the <div class="col-sm-4"><a href='[types termmeta="images-secondaires-categorie" raw="true"][/types]' data-rel="lightbox">

Normally, I should have for each occurence a <div class="col-sm-4"><a href='[types termmeta="images-secondaires-categorie" raw="true"][/types]' data-rel="lightbox"> for the related image.

For info, I'm using "responsive lightbox" plugin for lightbox here, but the issue is the same if I desable this plugin.
Can you help please?
Regards
Pat

#381896

Dear Pat,

Unfortunately, the Views shortcode [wpv-for-each] only works for the custom post field, see our document:
https://toolset.com/documentation/views-shortcodes/#wpv-for-each
Iterate through multiple items in a post meta field and output the enclosed text for each item. Including Types repeating fields.

In your case, I suggest you create another custom shortcode for it.
More help:
add_shortcode
http://codex.wordpress.org/Function_Reference/add_shortcode
get_term_meta
https://developer.wordpress.org/reference/functions/get_term_meta/

#381953

Pat

Hi Luo,
Just try to read the documentation but did not find where it is indicated that this will not work with term fields.
Perhaps it is obvious for you, but for let say, basic user, I would prefer to have a clear indication that this will not work with other things than custom fields?
Regards
Pat

#382293

As the document mentioned, it is for post meta field, it isn't for term meta field, then I check the source codes of Views plugin version 2.0:
\wp-views\embedded\inc\wpv-shortcodes.php, line 4238~4264:

function wpv_for_each_shortcode( $atts, $value ) {
...

	global $post;

	if ( !empty( $post ) ) {
		$meta = get_post_meta( $post->ID, $field );
...

As you can see it is read from post meta field.

And I put your request into our to-do list as a feature request, our developers will take care of it. but there isn't any ETA for it.

#382486

Hi Pat,

This is Mohammed from Toolset second tier support.

Unfortunately, Views doesn't support this feature but it's a nice feature that we wish to be added to Views.

I've reported this feature to the development team and it's already been added to our to-do list.

I'm closing this ticket but you always can check the newly added features to Views from the changelog page: https://toolset.com/download/toolset-views/#changelog .

Thanks and regards.

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