Skip Navigation

[Resolved] toolset_get_related_post meta_key comparison

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

Problem:

Your documentation says "Only limited values are supported for meta_compare ('=' | 'LIKE'). "

Does this means > < comparison operators are not allowed? https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

Solution:

Yes, you are right, it means > < comparison operators are not allowed. But you can try with WordPress built-in class WP_Query, add post type relationship parameter "toolset_relationships", see our document: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#advanced-example

section "Advanced example"

In the above codes, you can follow WP document to setup the post meta comparison operators:

https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters

Relevant Documentation:

This support ticket is created 4 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by pierreN 4 years ago.

Assisted by: Luo Yang.

Author
Posts
#2059903

Tell us what you are trying to do? Search by meta_value. I have a custom date field and I need to find records that matches any dates between last 7 days. I am using toolset_get_related_posts and not getting desired result.
Your documentation says "Only limited values are supported for meta_compare ('=' | 'LIKE'). "
Does this means > < comparison operators are not allowed?

Is there any documentation that you are following? Yes https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

Is there a similar example that we can see? hidden link (UNDER RECENT EVENTS)

What is the link to your site?

#2060749

Hello,

Yes, you are right, it means > < comparison operators are not allowed.

But you can try with WordPress built-in class WP_Query, add post type relationship parameter "toolset_relationships", see our document:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#advanced-example
section "Advanced example"

In the above codes, you can follow WP document to setup the > < comparison operators by following WP document:
https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters

#2061289

My issue is resolved now. Thank you!