i'm trying check if post has content, in loop. currently, added condition in loop :
if ( $post->post_content ) and putted argument in
wp query ('posts_per_page' => 8). i thought worked, actually, wp query go find last 8 posts, , check content of 8 lasts. renders 2 or 3 posts.
the thing want way show last 8 posts has content.
see mean ?
i appreciate :)
best regards.
this isn't possible standard wp query, , you'll have leverage use of posts_where before wp_query called.
function fitler_where($where = ''){ $where .= "and trim(coalesce(post_content, '')) <>''"; } in above, we're selecting posts column post_content isn't empty.
then add filter.
add_filter('posts_where', 'filter_where'); now perform query.
$query = new wp_query(array('post_type' => 'post', 'posts_per_page' => 8)); and when you're done, remove filter query doesn't interfere.
remove_filter('posts_where', 'filter_where');
Comments
Post a Comment