Tagged: post-relate
- This topic has 8 replies, 4 voices, and was last updated 6 years, 12 months ago by
dryan1144.
-
AuthorPosts
-
-
April 26, 2014 at 4:44 pm #1660
pupppetMemberTwo questions on post-relate:
– Is conditionally showing/hiding a post-relate field unsupported? Adding a condition to it doesn’t do anything, it always remains visible.
– Is it possible to include multiple post types in the scope? -
April 29, 2014 at 8:56 pm #1679
SteveKeymaster@pupppet– Showing/hiding seems to be a bug with the relate field. Supporting multiple scopes is interesting. I just tested multiple scopes like this
'scope' => array('post','page')and it seemed to work, but throws a bunch of warnings since most Piklist functions are not expecting an array. We’re going to have to think through if, and how, we want to support this. -
April 30, 2014 at 10:08 am #1682
JasonKeymasterI’m trying to think through a context in which it would be advantageous to have a single post-relate field with multiple post types versus a field for each one. I mean, Piklist aside, you get one field per taxonomy.
@puppet – Is there a reason to merge them instead of splitting them into multiple fields?
-
April 30, 2014 at 2:37 pm #1683
pupppetMemberIf we can get that conditional post-relate field bug fixed, there wouldn’t be a need to split them up as you could show/hide whichever post-relate is required. But I could see a situation where you may want multiple post types in the single post-relate field, for example if you have a large number of post types you aren’t necessarily going to want to have a large number of these post-relate fields conditionally showing/hiding, you’re bogging down the client with a lot of near duplicate code (not that it’s the end of the world or anything). ACF5 has a nifty post type dropdown to filter post-types you can include in its equivalent of Piklist’s post-relate field, might be a nice thing to copy.
-
February 10, 2015 at 12:09 pm #3299
dryan1144MemberCan I crack this thread open again? I’m trying to get a Post Relate field to show conditionally and ran into this bug – in my case the Post Relate field stays hidden no matter what selection is made on the controlling field.
-
February 10, 2015 at 4:27 pm #3300
SteveKeymasterPlease post your field code
-
February 10, 2015 at 4:41 pm #3301
dryan1144Memberpiklist('field', array( 'type' => 'radio', 'field' => 'portfolio_type', 'label' => __('Company Type'), 'description' => __('Select a Type'), 'value' => 'platform', 'choices' => array( 'platform' => 'Platform', 'addon' => 'Add-on', ) )); piklist('field', array( 'type' => 'post-relate', 'scope' => 'portfolio', 'label' => 'Add Ons', 'conditions' => array( array( 'field' => 'portfolio_type', 'value' => 'platform' ) ) )); -
February 11, 2015 at 12:59 pm #3302
SteveKeymasterYup… this still doesn’t work 😉
We currently rethinking the Post Relate field. If you need this type of functionality right away, you may want to try a standard checkbox:
piklist('field', array( 'type' => 'checkbox', 'field' => 'portfolio_relate', 'label' => __('Add Ons'), 'value' => 'platform', 'choices' => piklist( get_posts( array( 'post_type' => 'post' ,'orderby' => 'post_title' ) ,'objects' ) ,array( 'ID' ,'post_title' ) ), 'conditions' => array( array( 'field' => 'portfolio_type', 'value' => 'platform' ) ) ));Let us know if that works for you.
-
February 11, 2015 at 1:07 pm #3303
dryan1144MemberThanks for the code – it works well enough except for the fact that the list of options can easily get ridiculously long in this particular situation. Unless we set a height on the checkbox container and scroll…
Interested to see what you guys have coming for the Post Relate field, it’s one I use often. I’m sure you’ve seen how CMB/CMB2 does theirs – basically a search/dropdown select with a repeater field. Really nice UI.
Thanks for the help.
-
-
AuthorPosts
- You must be logged in to reply to this topic.