Nested Looper for two types of custom fields plus taxonomy

Hi there,

I’d like to get back to my previous post:

Even after having watched the videos @ruenel suggested, I was so frustrated that I did not want to touch it for a couple of weeks.

Thing is: The tutorials listed my @ruenel demonstrate the case where all consumers and provider refer to the same custom field group.

In my case however, I want to loop through two different sets of custom fields. I have a custom post type “Learning Content” that houses all my learning items. And then I have various “Memberships” which are, in turn, also custom fields with their titles and descriptions. I created sections to house the membership ‘categories’ a user is subscribed to. The slides within each section shall then display the Learning Content of the specific Membership category they belong to.

If that helps: In order to be able to group my items by membership category, each learning content item (=slide) has additionally a taxonomy of my individual membership ‘category’: “SBI Academy Free”, “… Premium” etc.

The I tried to write a query string into my slide container like this;

post_type%3Dlearning-content%26tax_query%5B0%5D%5Bterms%5D%3D%7B%7Bdc%3Aterm%3Aslug%7D%7D%26posts_per_page%3D20%26post_status%3Dany

To no avail.

Could you please help me out again on how to do it?

Regards,
Jens

Hello @Paritor,

Thanks for writing in! You will need to distinguish your query argument first. For example, to display the Learning Contents that belong to SBI Academy Free the argument will be like this:

$meta_query[] = array(
    'key'     => 'related_membership',
    'value'   => 821, // it is the ID of SBI Academy Free
);

$query = array(
    'post_type'  => 'learning-content',
    'meta_key'   => 'related_membership',
    'posts_per_page'    => -1,
    'post_status'      => 'any',
    'meta_query' => $meta_query
);

Hope this helps.

Thank you @ruenel! I’ll try it out.

Jens

Hello Jens,

Please let us know how it goes.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.