Skip to:
Content
Pages
Categories
Search
Top
Bottom

Delete topic doesn't delete replies


  • inspirationally
    Participant

    @inspirationally

    I just cleaned my forum from some old like “what are you listening to?” topics, means around 1000 replies each, and wondered, why the replies number did not decrease after emptying the topics trash.

    Well – the replies are all still there, that’s the reason, see http://johnny-depp.org/forums/reply/160965/

    Why is that and how can I have them deleted, too, when I delete a topic?
    And how can I now delete all the orphan replies + postmeta? The WP Optimize plugin doesn’t catch them.

    Thank you, Martina.

Viewing 4 replies - 1 through 4 (of 4 total)

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    That’s interesting. They should definitely be getting deleted. How did you delete your topics? Admin-side, or theme-side?


    inspirationally
    Participant

    @inspirationally

    Admin side.
    Theme side nothing happens (side is white…)

    Something bad happens with my bbPress installation – first the revisions, now that 🙁


    inspirationally
    Participant

    @inspirationally

    ok, got it.
    I was sorting the topics by number of replies with this:

    <?php
    /*
    Plugin Name: Set Post Order In Admin
    Version: 0.1
    Plugin URI: https://wordpress.org/support/topic/336715/
    Description: In Posts->Edit, display posts in title order.
    Author: MichaelH
    Author URI: https://codex.wordpress.org/User:MichaelH/MyPlugins
    */
    
    function set_post_order_in_admin( $wp_query ) {
      if ( is_admin()) {
    
    $wp_query->set( 'orderby', 'meta_value_num' );
    $wp_query->set( 'meta_key', '_bbp_reply_count' );
        $wp_query->set( 'order', 'DESC' );
      
    }}
    
    add_filter('pre_get_posts', 'set_post_order_in_admin' );
    ?>

    this seems to cause the replies not to be deleted, too, curiously.`

    Any idea why this happens? And how to delete the orphan replies + postmeta.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    That will definitely cause you some grief. pre_get_posts is called on every posts query that fires, even non-bbPress ones.

    In this case, you’re filtering every admin query and looking for a meta value that won’t exist for certain post types (like revisions, pages, posts, attachments, navigation menus, etc…)

    You’ll want to target your code much more specifically than you are here, so that you’re only matching the correct query conditions for what you’re trying to accomplish. This might be hard if you’re also trying to filter sidebars and widgets, since you want something broad, but not too broad.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar