I have done more investigation and confirmed the bug in WordPress 4.0.1. Leaving MLA completely out of the loop, this code:
function test_date_query() {
global $wp_query;
$args = array(
'post_status' => 'inherit',
'tax_query' => array(
array(
'taxonomy' => 'attachment_category',
'field' => 'slug',
'terms' => 'new-category'
)
),
'date_query' => array(
array(
'after' => '-12 months'
)
)
);
$query = new WP_Query( $args );
}
causes WP_Query to generate this query:
SELECT SQL_CALC_FOUND_ROWS mladev_posts.ID
FROM mladev_posts
INNER JOIN mladev_term_relationships
ON (mladev_posts.ID = mladev_term_relationships.object_id) LEFT JOIN mladev_posts AS p2
ON (mladev_posts.post_parent = p2.ID)
WHERE 1=1
AND ( ( post_date > '2013-12-18 12:03:41' ) )
AND ( mladev_term_relationships.term_taxonomy_id IN (167,184) )
AND mladev_posts.post_type = 'attachment'
AND (((mladev_posts.post_status = 'inherit')
OR (mladev_posts.post_status = 'inherit'
AND (p2.post_status = 'inherit'))))
GROUP BY mladev_posts.ID
ORDER BY mladev_posts.post_date DESC
LIMIT 0, 2
which fails with this message:
Column 'post_date' in where clause is ambiguous
Removing the ‘post_status’ => ‘inherit’ element eliminates the error. Replacing ‘post_status’ => ‘inherit’ with ‘post_type’ => ‘attachment’ also avoids the problem.
I have also confirmed that this bug is fixed in WordPress 4.1, which has been released. If you are in a position to upgrade to the new version, it is the easiest way to solve the problem. If not, let me know and I will work out an interim fix for you.
The <code></code
tags are still required around the first shortcode on the page, sadly.
I am marking this topic resolved because it is a WordPress bug and has been fixed. If you need an interim solution, post an update here and I will work it out for you. Thanks again for your patience and for your interest in the plugin.