Support » Plugin: ACF: Better Search » WordPress database error

  • Resolved ac

    (@ljxdm)


    Using WP 5.8 and version 3.9.1 I get this error when searching pages or posts within the CMS (not front end. i have Error reporting enabled). All searches return no results, only this error. Disabling the plugin, everything works again (though obviously not searching ACF content).

    WordPress database error:
    
    [Column 'post_date' in order clause is ambiguous]
    
    SELECT DISTINCT   wp_posts.ID, wp_posts.post_parent FROM wp_posts  INNER JOIN wp_postmeta AS a ON (a.post_id = wp_posts.ID) LEFT JOIN wp_postmeta AS b ON (((b.meta_id = a.meta_id + @@auto_increment_increment)) AND ((b.meta_key LIKE CONCAT('\_', a.meta_key)))) LEFT JOIN wp_posts AS c ON ((c.post_name = b.meta_value) AND (c.post_type = 'acf-field') AND ((c.post_content LIKE '%:"text"%') OR (c.post_content LIKE '%:"textarea"%') OR (c.post_content LIKE '%:"url"%') OR (c.post_content LIKE '%:"wysiwyg"%')))  WHERE 1=1  AND (((b.meta_id IS NOT NULL) AND (c.ID IS NOT NULL) AND (a.meta_value LIKE '%green%')) OR ((wp_posts.post_title LIKE '%green%') OR (wp_posts.post_content LIKE '%green%') OR (wp_posts.post_excerpt LIKE '%green%')))  AND wp_posts.post_type = 'page' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_status = 'private')  ORDER BY post_date DESC, wp_posts.menu_order ASC, wp_posts.post_title ASC
    • This topic was modified 1 year ago by ac.
    • This topic was modified 1 year ago by ac.
    • This topic was modified 1 year ago by ac. Reason: formatting
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hello @ljxdm,

    Thanks for your message.

    Do you use a function or other plugin that modifies the content of the database query?

    Best,
    Mateusz

    Thread Starter ac

    (@ljxdm)

    Nope. Seems like an easy fix though – just specify the table for post_date in Order?.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @ljxdm My plugin does not add the problem part to the query:
    ORDER BY post_date DESC

    This plugin only adds query fragments in the LEFT JOIN and WHERE parts.

    Thread Starter ac

    (@ljxdm)

    I’d suggest it was a naming conflict with one of my ACF fields but I don’t have one called post_date.

    Interestingly, it works without error if I enable “Lite Mode”.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @ljxdm The problem part of the database query was not added by this plugin. Unfortunately, in this situation, I am not able to say anything more.

    Your field names are irrelevant. If there was a problem with the plugin it was reported by someone. Many people use the plugin. I hope that you understand me. I would like to help, but it is not the fault of the plugin.

    Thread Starter ac

    (@ljxdm)

    Thanks, totally understand.

    Thread Starter ac

    (@ljxdm)

    @mateuszgbiorczyk just to let you know, we found the source of this error elsewhere. thanks for your help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WordPress database error’ is closed to new replies.