Title: Started getting this ambiguous sql error
Last modified: August 22, 2016

---

# Started getting this ambiguous sql error

 *  Resolved [Matt](https://wordpress.org/support/users/syntax53/)
 * (@syntax53)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/started-getting-this-ambiguous-sql-error/)
 * > [15-Jan-2015 02:16:01 UTC] WordPress database error Column ‘post_date’ in where
   > clause is ambiguous for query SELECT wp_2_posts.* FROM wp_2_posts INNER JOIN
   > wp_2_term_relationships ON (wp_2_posts.ID = wp_2_term_relationships.object_id)
   > LEFT JOIN wp_2_posts AS p2 ON (p2.ID = p2.ID) WHERE 1=1 AND (
   >  wp_2_term_relationships.
   > term_taxonomy_id IN (3) ) AND wp_2_posts.post_type = ‘attachment’ AND (((wp_2_posts.
   > post_status = ‘inherit’) OR (wp_2_posts.post_status = ‘inherit’ AND (p2.post_status
   > = ‘inherit’)))) AND (`post_date` > ‘2014-12-15’ OR `post_type` != ‘page’) GROUP
   > BY wp_2_posts.ID ORDER BY wp_2_posts.post_title ASC made by require(‘d:\path\
   > to\wp\wp-blog-header.php’), require_once(‘d:\path\to\wp\wp-includes\template-
   > loader.php’), include(‘d:\path\to\wp\wp-content\themes\asd-custom\index.php’),
   > get_template_part, locate_template, load_template, require(‘d:\path\to\wp\wp-
   > content\themes\asd-custom\content.php’), custom_excerpt_length, do_shortcode,
   > preg_replace_callback, do_shortcode_tag, call_user_func, MLAShortcodes::mla_gallery_shortcode,
   > MLAShortcodes::mla_get_shortcode_attachments, WP_Query->query, WP_Query->get_posts
 * [https://wordpress.org/plugins/media-library-assistant/](https://wordpress.org/plugins/media-library-assistant/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [Matt](https://wordpress.org/support/users/syntax53/)
 * (@syntax53)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/started-getting-this-ambiguous-sql-error/#post-5673272)
 * post edited — I was wrong, the shortcode i originally posted was not causing 
   this. trying to figure out what is.
 *  Thread Starter [Matt](https://wordpress.org/support/users/syntax53/)
 * (@syntax53)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/started-getting-this-ambiguous-sql-error/#post-5673307)
 * So it is being caused by the shortcode I thought it was, but not when displayed
   directly on the page. It’s being caused by a custom function I wrote that creates
   an excerpt from the content of the page when “get_the_excerpt()” returns nothing
   in a list of recent posts. My function is as follows–
 *     ```
       function custom_excerpt_length($length){
       	$excerpt = do_shortcode( get_the_content() );
       	$excerpt = strip_tags($excerpt, '<br><li><p>');
       	$excerpt = str_ireplace(array('<br>'), array(', '), $excerpt);
       	$excerpt = str_ireplace(array('<li>','</li>'), array(', ', ''), $excerpt);
       	$excerpt = str_ireplace(array('<p>','</p>'), array(', ', ''), $excerpt);
       	while (substr($excerpt, 0, 1) == ',') { $excerpt = substr($excerpt, 1); }
       	$excerpt = trim($excerpt);
       	if (strlen($excerpt) > $length) {
       		$permalink = get_permalink();
       		$excerpt = substr($excerpt, 0, $length);
       		$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
       		$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
       		$excerpt = $excerpt.'... <a href="'.$permalink.'">more</a>';
       	}
       	return $excerpt;
       }
       ```
   
 * The “$excerpt = do_shortcode( get_the_content() );” is causing it. This is being
   ran in the loop on a homepage set to show the most recent posts. The shortcode
   is–
 * [mla_gallery mla_link_attributes=’rel=”none”‘ attachment_category=board-governance
   mla_style=mla-policy-list-ul mla_markup=mla-policy-list-ul post_parent=all orderby
   =title order=asc post_mime_type=all link=file]
 *  Thread Starter [Matt](https://wordpress.org/support/users/syntax53/)
 * (@syntax53)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/started-getting-this-ambiguous-sql-error/#post-5673311)
 * fyi– i tried updating to the latest development version and it did not fix it.
 *  Thread Starter [Matt](https://wordpress.org/support/users/syntax53/)
 * (@syntax53)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/started-getting-this-ambiguous-sql-error/#post-5673315)
 * wow, ok. I tracked it back even further to another custom function that I wrote
   where I was hooking “pre_get_posts” to add pages to the loop, but only if they
   were 1 month old or newer. I just had to modify that query to include the table
   name ($wpdb->prefix.’posts’). I guess you are also hooking that somewhere? Either
   way, ignore my ramblings I suppose 🙂
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/started-getting-this-ambiguous-sql-error/#post-5673327)
 * Thanks for tracking this down and resolving it before I could muddy the waters.
   As you suspected, MLA hooks quite a few filters to support the query enhancements
   in, for example, `[mla_gallery]`.
 * I have been on both sides of the “warring filters” experience and I can relate
   to your adventures.
 * If there’s anything else I can do to make your MLA experience better, let me 
   know. Thanks for your persistence and your interest in the plugin.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Started getting this ambiguous sql error’ is closed to new replies.

 * ![](https://ps.w.org/media-library-assistant/assets/icon-256x256.png?rev=973502)
 * [Media Library Assistant](https://wordpress.org/plugins/media-library-assistant/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/media-library-assistant/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/media-library-assistant/)
 * [Active Topics](https://wordpress.org/support/plugin/media-library-assistant/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/media-library-assistant/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/media-library-assistant/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [David Lingren](https://wordpress.org/support/users/dglingren/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/started-getting-this-ambiguous-sql-error/#post-5673327)
 * Status: resolved