WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
Co-authors order when duplicate post (4 posts)

  1. alexpike
    Member
    Posted 2 years ago #

    Hi. Have an interesting issue. I use Duplicate post plugin so when i duplicate some post the order of author and co-authors changes as usual.
    What i mean exactly:
    in original post
    Author 1
    Author 2
    Author 3
    Author 4
    when duplicate
    Author 3
    Author2
    Author 1
    Author 4

    Is it possible to fix it cause i need the same authors order as in original post?

    http://wordpress.org/extend/plugins/co-authors-plus/

  2. Sergey Biryukov
    WordPress Dev
    Posted 2 years ago #

    The solution here would actually be to preserve the order of taxonomy terms in Duplicate Post plugin.

    1. In duplicate-post-admin.php, find duplicate_post_copy_post_taxonomies() function (line 344 in Duplicate Posts 1.1.2).
    2. Find this code:
      $post_terms = wp_get_object_terms($id, $taxonomy);
      for ($i=0; $i<count($post_terms); $i++) {
      	wp_set_object_terms($new_id, $post_terms[$i]->slug, $taxonomy, true);
      }
    3. Replace with:
      $post_terms = wp_get_object_terms($id, $taxonomy, array( 'orderby' => 'term_order' ));
      $terms = array();
      for ($i=0; $i<count($post_terms); $i++) {
      	$terms[] = $post_terms[$i]->slug;
      }
      wp_set_object_terms($new_id, $terms, $taxonomy, false);
  3. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    @lopo What do you think about making this improvement to your Duplicate Post plugin?

  4. lopo
    Member
    Posted 2 years ago #

    I will defitely add it to next version, thanks for the suggestion!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic