Skip Navigation

[Resolved] when using toolset_get_related_posts and trying to use a meta_compare no results

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

Problem:

There is a mysql error when use function toolset_get_related_posts() with meta query args.

Solution:

Our developers have provided a hot-fix here:

https://toolset.com/errata/toolset-api-toolset_get_related_posts-meta_key-query-is-producing-a-wordpress-database-error/

Relevant Documentation:

This support ticket is created 6 years, 7 months 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 7 replies, has 3 voices.

Last updated by Ralph 6 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#948737

Tell us what you are trying to do?
I'm trying to query the child posts where the field wpcf-concert-in-past is = 0

$concertsforvenue = toolset_get_related_posts(
$venueId,
'venue-concert',
'parent',
100,
0,
array(
'meta_key' => 'wpcf-concert-in-past',
'meta_compare' => '=',
'meta_value' => '0'
),
'post_object',
'child',
'title',
'ASC',
true,
$concountthing
);

if I take out the content of the array it returns the three records that exist. One of those has the custom field set to 1.

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

Is there a similar example that we can see?

What is the link to your site?
hidden link

#948937

Hello,

In your PHP codes, the 'meta_value' is '0', it is "1".

Please check these:
1) There exists 'venue-concert' posts with custom field "concert-in-past" settings, and the field values are 0, if you want to compare with value "1", you will need to change to "meta_value" to 1

3) Deactivate other plugins and switch to wordpress default theme 2017, and test again

4) If the problem still persists, please provide a database dump file (ZIP file) of your website in below "private detail box", I need to duplicate same problem and debug it in my localhost, thanks.

#949029

The database dump file is not valid, I get lots of MYSQL errors when import it.

Since it is a custom PHP codes problem, please provide a test site with the same problem, and fill below private message box with login details, and FTP access, also point out the problem page URL and where I can edit your PHP codes, I need to test and debug it in a live website.

#950084

Thanks for the details, I can login your website, and will update this thread if there is anything news.

#950110

Thanks for the details, I can duplicate the same problem, and I get some MYSQL error when setup the meta query in the function toolset_get_related_posts():

WordPress database error: [Unknown column 'wp_postmeta_1' in 'where clause']

It should be a bug of function toolset_get_related_posts(), I have escalated it, will update here if there is anything news.

#955405

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Luo is on Vacation. I'm just adding a comment here to update you that:

This issue will be fixed with next release of Types plugin version 3.0.7.

#1077316

Our developers have provided a hot-fix here:
https://toolset.com/errata/toolset-api-toolset_get_related_posts-meta_key-query-is-producing-a-wordpress-database-error/

Please test it and feedback if it is fixed, thanks

#1080678

the patch file is working.