WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Delete Posts Without Comments, Automatically (3 posts)

  1. HNORTHWAY
    Member
    Posted 12 months ago #

    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?

  2. HNORTHWAY
    Member
    Posted 11 months ago #

    I'm more than willing to pay for this help!

  3. esmi
    Forum Moderator
    Posted 11 months ago #

    Please try http://directory.codepoet.com/

    This topic has now been closed as per the Forum Rules

Topic Closed

This topic has been closed to new replies.

About this Topic