WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Does not sync the sorted list when updated the post

[Resolved] Does not sync the sorted list when updated the post

  • Hi, I’m japanese programmer.
    This is very nice plugin!

    Maybe, I found the bug.
    It is below.

    Environment:
    I use the version 1.2.4.

    Steps:
    1. ‘Post A’ and ‘Post B’ belongs to the ‘Test Category’.
    2. Set order to the ‘Post A’ and ‘Post B’ in ‘Test Category’.
    3. Confirm the ‘Post A’ and ‘Post B’ in the sorted list.
    4. Remove the ‘Test Category’ from the ‘Post A’.
    5. Show the sorted list of ‘Test Category’.
    6. Still the ‘Post A’ is remained to sorted post list!

    I fixed the this bug.
    The fixed code is below.

    1. Add function to action hook to near line 21:
    add_action( 'save_post', array( 'q2w3_post_order', 'update_post_sync' ) );

    2. Add the function in q2w3_post_order class:

    public static function update_post_sync($post_id) {
    
    	global $wpdb;
    
    	$post = get_post($post_id);
    
    	if (empty($_POST['tax_input'])) {
    		return;
    	}
    
    	foreach ($_POST['tax_input'] as $tax_name => $term_id) {
    		$sql = $wpdb->prepare('DELETE FROM ' . self::posts_table() . ' WHERE post_id = ' . $post_id . ' AND term_id NOT IN (' . implode(', ', $term_id) . ') AND taxonomy = \'' . $tax_name . '\'');
    		$wpdb->query($sql);
    	}
    }

    Could you confirm this?

    http://wordpress.org/extend/plugins/q2w3-post-order/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Does not sync the sorted list when updated the post’ is closed to new replies.