WordPress.org

Forums

Posts 2 Posts
[resolved] Ordering connected posts (5 posts)

  1. JsonB123
    Member
    Posted 4 years ago #

    Is ordering at all possible via the orderby and order parameters? If so, where do these go, under filters?

    I was assuming that at least the order I connected the posts to a post would stay, but upon reloading the page, it wasn't so. Not sure what order they are behaving by either; it's not alphabetical nor is it by post ID.

    Also, just wanted to note how much I LOVE this plugin. Well done Scribu! Quality work as always.

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. scribu
    Member
    Plugin Author

    Posted 4 years ago #

    Thanks for the kind words, but I can't take all the credit for this release. :)

    On the front-end, you can order them like so:

    $connected = get_posts( array(
      'suppress_filters' => false,
      'connected' => $post->ID,
      'post_type' => 'foo',
    
      'orderby' => 'title',
      'order' => 'asc'
    ) );

    If you need explicit ordering, a potential solution would be to define an 'order' field, which you then populate manually (like ye olde menu_order for pages).

    Then, you would have to do some SQL hacking to make use of that custom 'order' field.

  3. Dave James Miller
    Member
    Posted 4 years ago #

    I was just wondering something similar - ideally I'm looking for some way to drag-drop the connected posts into order in the admin, then retrieve them in that order every time.

    I also wanted to say thanks for this plugin - it was very useful in a recent project of mine.

  4. non_human
    Member
    Posted 4 years ago #

    Then, you would have to do some SQL hacking to make use of that custom 'order' field.

    Scribu, can you help with the example of that, please?
    If there's p2p meta_key = "order" and values "1", "2"..etc. how would you connect posts with p2pmeta table? custom SQL query with inner join?

  5. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    @non_human: There's now an API for that:

    https://github.com/scribu/wp-posts-to-posts/wiki/Connection-ordering

    ideally I'm looking for some way to drag-drop the connected posts into order in the admin, then retrieve them in that order every time.

    The development version (0.9-alpha2) has the drag-and-drop part.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic