Tagged: 

Viewing 8 reply threads
  • Author
    Posts
    • #3128
      jcrist
      Member

      Is there any way to sort the related posts? For example, I’m working on a lawyer website where we have a CPT for areas of practice and the attorney profiles will have a relationship to them. However, a lawyer may focus on one AOP and want it displayed first.

      Happy holidays

    • #3130
      Steve
      Keymaster

      Currently the Post Relationship field cannot be modified.

      However, you can do something similar if you want.

      In Piklist demos > Advanced Tab > Content Section (Grouped) field. We pull in Posts.

      You can use this field as a guide to create your own. The Post ID would be saved as meta which you can query using get_posts.

      Let us know if you need help.

    • #3133
      jcrist
      Member

      Thanks for the tip, Steve. This should work just fine for one-way relationships but say I also wanted to display the lawyers on the AOP page?

    • #3134
      Steve
      Keymaster

      You should be able to use Meta Query to go the other way. Let me know if that works for you.

    • #3511

      Steve – thanks for the insight. I have a similar case to jcrist.

      Can you tell me where I could see the code to produce that particular demo? I’m an experienced php / wp dev, but new to wp. I’ve poked around the /add-ons/piklist-demos directory in the plugin, but didn’t find it.

    • #3513
      Steve
      Keymaster

      @gustavolanzas– Welcome to the Piklist community!

      The demo I was talking about can be found here: piklist/add-ons/piklist-demos/parts/meta-boxes/field-add-more.php

      We pull in posts and display them in a dropdown.

      Let me know if that was not what you were asking about.

    • #3515
      jcrist
      Member

      While the solution did work just fine, it feels a little cumbersome. I saw a post somewhere that said you are rethinking the post-relate, any insight on that?

      I have an idea, and I’m sure you’ve have one similar but I’ll throw it out there anyway — allow users to sort related-posts inside of the meta-box like http://jsfiddle.net/PtskU/ so the order is customizable on a post-by-post basis. I figure that since there’s a new table in the DB for post-relationships, you could add something like the menu_order column in wp_posts.

    • #3518
      Steve
      Keymaster

      @jcrist– Nice idea! I don’t think we need to add the column since it’s already in wp_post. We can just add an orderby parameter. We are rethinking post-relate, but any changes probably won’t happen until after we release 0.9.5.

    • #3520
      jcrist
      Member

      This might be a bit specific for my use but I was thinking that the related-posts could be ordered on a page-by-page basis. For example, on the attorney/aop instance above, Attorney1 wants AOP2 to display first while Attorney2 wants AOP1 first.

      Kind of like what ACF does with their relationship field, but keeping it inside a taxonomy box and keeping it (mostly) the wordpress way. This would require the order to be saved in either post_meta or somewhere else right? I suggested an additional column so you wouldn’t have to query the postmeta just to get the order.

Viewing 8 reply threads
  • You must be logged in to reply to this topic.