Below is an example — tested and worked.
The SQL query is:
AND ({$wpdb->posts}.post_content != '' OR {$wpdb->posts}.post_excerpt != '')
And the example:
<?php
// This would be in functions.php or somewhere else where appropriate.
function posts_where_require_content_or_excerpt( $where, $wp_query ) {
global $wpdb;
$where .= " AND (" .
" {$wpdb->posts}.post_content != ''" .
" OR {$wpdb->posts}.post_excerpt != ''" .
")";
return $where;
}
// -- SAMPLE IMPLEMENTATION --
add_filter( 'posts_where', 'posts_where_require_content_or_excerpt', 10, 2 );
query_posts( array(
'post_type' => 'post',
'posts_per_page' => 5,
'ignore_sticky_posts' => true,
) );
remove_filter( 'posts_where', 'posts_where_require_content_or_excerpt', 10, 2 );
if ( have_posts() ) {
echo '<ul>';
while ( have_posts() ) {
the_post();
echo '<li>';
echo '<h2>'; the_title(); echo '</h2>';
echo '<p>'; the_excerpt(); echo '</p>';
printf( '<p><a href="https://wordpress.stackexchange.com/questions/294863/%s">Read More →</a></p>',
esc_url( get_permalink() ) );
echo '</li>';
}
echo '</ul>';
//the_posts_pagination(); // Needs extra work.
}
wp_reset_query();