View difference between Paste ID: 4mSF72EB and qUDgAUA7
SHOW: | | - or go back to the newest paste.
1
add_post_type_support( 'page', 'excerpt' );
2
3
function posts_where_excerpt_not_empty( $where ) {
4-
    // on the home page 
4+
    // on the home page or a category page
5-
    if(is_home()){
5+
    if(is_home() || is_category()){
6
    $where .= " AND post_excerpt != '' ";
7
    }
8
    return $where;
9
}
10
add_filter( 'posts_where' , 'posts_where_excerpt_not_empty' );
11
12
function my_post_queries( $query ) {
13
  // not an admin page and is the main query
14
  if (!is_admin() && $query->is_main_query()){
15-
    // on the home page
15+
    // on the home page or a category page
16-
    if(is_home()){
16+
    if(is_home() || is_category()){
17
      $query->set('post_type', array('post', 'page'));
18
    }
19
  }
20
}
21
22
add_action( 'pre_get_posts', 'my_post_queries' );