WordPress.org

Forums

Q2W3 Post Order
[resolved] Does not sync the sorted list when updated the post (3 posts)

  1. jyokyoku
    Member
    Posted 3 years ago #

    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/

  2. Max Bond
    Member
    Plugin Author

    Posted 3 years ago #

    jyokyoku!
    Thanks!
    I'll check your code at weekend.

  3. Max Bond
    Member
    Plugin Author

    Posted 3 years ago #

    jyokyoku!
    Thank you for report and code sample!
    I have embeded it (with little changes) in ver. 1.2.6

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Q2W3 Post Order
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.