Tagged: conditional meta fields, dropdown, images, upload, widgets
- This topic has 4 replies, 2 voices, and was last updated 8 years, 9 months ago by
Steve.
-
AuthorPosts
-
-
May 3, 2013 at 11:15 pm #816
badlydrawnrobMemberIt’s always best to have one widget rather than multiple that essentially do the same thing. I’m using some simple if/else statements for the widget output but it would be really handy for the user to set these options before-hand, a simple example would be:
- insert image dropdown yes/no
- if “yes” use can enter an image url
- if “no” theres someway to remove the image tag from the output
I guess similar to your “add_more” field, but with a disable/enable option.
-
May 6, 2013 at 9:33 am #817
SteveKeymaster@badlydrawnrob– The difference between Piklist and other “similiar” systems is that Piklist just makes WordPress easier… but it’s still WordPress. Just use standard conditionals to show/hide fields.
1. insert image dropdown yes/no: This is a Piklist SELECT field.
2. if “yes” use can enter an image url
3. if “no” theres someway to remove the image tag from the outputFor steps 2 and 3 use the standard WP function, get_option(), to get the value of step 1. Then wrap the output in the conditional. If true: show the output.
Does this make sense?
-
May 11, 2013 at 3:01 am #822
badlydrawnrobMember@sbruner Ok, so that did make sense although I had to do a lot of digging, and a lot of trial and error … here’s my experience so far:
Conditional meta fields doesn’t work for widgets unless I’m mistaken: WordPress doesn’t load any widget areas in admin when using this setup with this widget (I’m pretty sure the code on the widget is wrong, but it won’t have affected the whiteout issue (the issue is always resolved by removing the select dropdowns)
I finally managed to make the conditional statements work (I tried a few different ways as the get_options() docs are pretty sparse. However, for the life of me I can’t figure out why all the if/elseif statements won’t be working with wp_list_pages(). You can check out my code here, along with the failed attempt.
Again, I’m a beginner in PHP so I might be missing something, though I can’t think what. Would appreciate any feedback you can give.
-
May 12, 2013 at 3:18 pm #824
badlydrawnrobMemberSo after talking to a php friend the if/else issue with wp_list_pages() is due to me not understanding the specificity of conditionals properly. Still no further with that one but at least I know it’s my fault!
It’d be helpful to get feedback on the user-admin side of things though, and if the conditional fields is currently only for settings pages, if it should work on the widget admin, or if I’m just doing something wrong.
-
May 15, 2013 at 9:34 am #826
SteveKeymasterCan you give us a specific example of what you want to achieve?
-
-
AuthorPosts
- You must be logged in to reply to this topic.