• I would like to be able to have a function that will delete any posts without comments. I have tried some different things, this being among the more promising (http://wordpress.stackexchange.com/questions/102034/display-only-posts-with-comments):
    /* Shortcode to output recent posts from one category */
    function display_cat_recent_posts() {
    $args = array(
    ‘post_type’ => ‘post’,
    ‘posts_per_page’=> 5,
    ‘cat’=> 1,
    );

    $cat_recent_posts = new WP_Query( $args );

    if ( $cat_recent_posts->have_posts() ):
    $output = ‘

      ‘;
      while ( $cat_recent_posts->have_posts() ) : $cat_recent_posts->the_post();
      if ( get_comments_number( ) > 0 ):
      $output .= ‘

    • ‘ . get_the_title() . ‘
    • ‘;
      endif;
      endwhile;

    $output .= ‘
    ‘;
    endif;

    return $output;

    wp_reset_postdata();
    }

    add_shortcode( ‘recent-posts’, ‘display_cat_recent_posts’ );

    But in the end, nothing has worked. Can anyone help?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Delete Posts Without Comments, Automatically’ is closed to new replies.