Advanced Custom Fields on venue
WordPress Event Management, Calendars & Registration › Forums › General Question › Advanced Custom Fields on venue
This topic contains 6 replies, has 2 voices, and was last updated by José Morin 10 years ago.
-
AuthorPosts
-
November 23, 2014 at 8:19 pm #13620
Hi,
When creating a field groups on Advanced Custom Fields, I can set a rule to display it on an event edit page. Unfortunately, I don’t see how to display it on a venue edit page. Is there a way to use Advanced Custom Fields on venue?
Since venue are taxonomy, I should normaly be able to use ACF on Taxonomy term edit page, as explain here.
When i edit my ACF field group, I can add a rule to select which taxonomy I wish for the field group to show on. If I set “Event tags”, the field group will indeed be display on an event tag edit page. But if I select “Venue”, it is not. I guess it is because an event tag and a venue are not using the same kind of edit page: the first one uses “edit-tags.php?taxonomy=event-tag&post_type=event” while the second one “edit.php?post_type=event&page=venues”. I don’t see why since both are taxonomy term.
Anyway, I’m working on the website of a 10 year old amateur festival where events are located in many venues. I would really like to be able to add boolean field and if possible checkbox and date
Here is the kind of field I would like to add:
– Open: true/false (radio)
– Participation: 2010, 2011, 2012, 2013, 2014 (checkbox)
– Opening date: dd/mm/yyyy (date)Do you think there is a way to do it?
Thanks a lot in advance,-
This topic was modified 10 years, 3 months ago by
José Morin.
José Morin
November 24, 2014 at 6:15 pm #13629HI José,
I see – I hadn’t realised that ACF also supports taxonomies. The reason why they don’t appear is (as you’ve spotted), the admin page for venues is different – this was the layout of the default taxonomy page was not suitable for managing venues. Unfortunately, this means that ACF doesn’t work with Event Organiser venues – that said, I suspect that it would be possible to get the two to work together, and I’ll look into that for you. If not (or if you prefer), I could provide the code for creating those fields on the venue admin page.
Stephen Harris
November 24, 2014 at 10:50 pm #13635That would be great if you can have a look. Depending on the time you’ve got, either solutions are fine for me (and more than I expected). Of course, it would be better to be able to use ACF, since it is a really well done plugin that is widely used, but I can perfectly create those field myself if not possible.
Thanks a lot!
José Morin
November 26, 2014 at 12:43 pm #13651No worries José – after looking at ACF it does seem possible but I believe it would be generally easier to add the fields yourself. So I’ll be in touch in the next day or two with the necessary code to do that.
I will also contact the author of ACF to see if some improvements might be made to the plug-in to facilitate integration with custom admin pages.
Stephen Harris
February 17, 2015 at 5:47 pm #15123Hi Stephen,
if you have the time to give me the necessary code to use advanced custom field on a venue page, it would be great.
Here is the kind of field I would like to add:
– Open: true/false (radio)
– Participation: 2010, 2011, 2012, 2013, 2014 (checkbox)
– Opening date: dd/mm/yyyy (date)The first one (boolean field) being the most important for me.
Thank you a lot in advance,José Morin
February 17, 2015 at 6:24 pm #15124Hi Jose,
Apologies, this one slipped the radar.
Here’s the general code for creating custom metaboxes: http://wp-event-organiser.com/documentation/developers/venue-meta-data-and-metaboxes/
The example in the tutorial is just a text input:
<?php $time = eo_get_venue_meta($venue->term_id, '_opening_times',true); ?> <label> Opening times:</label> <input type="text" name="my_opening_time" value="<?php echo esc_attr($time);?>" >
But you can change that to anything. E.g. radio:
<?php $open = eo_get_venue_meta($venue->term_id, 'open' ,true ); ?> <label> Open:</label> <input type="radio" name="my_open" value="1" <?php checked( $open ); ?> /> <input type="radio" name="my_open" value="0" <?php checked( !$open ); ?> />
(The
checked()
function just printschecked="checked"
if the argument resolves to true).Checkboxes are similar:
<?php $participation = eo_get_venue_meta($venue->term_id, 'participation' ,true ); ?> <h3>Participation</h3> <input type="checkbox" id="participation-2010" name="my_participation[]" value="2010" <?php checked( in_array( 2010, $participation ) ); ?> /><label for="participation-2010"> 2010</label> <input type="checkbox" id="participation-2011" name="my_participation[]" value="2011" <?php checked( in_array( 2011, $participation ) ); ?> /><label for="participation-2011"> 2011</label>
Here I’ve used the meta keys
open
andparticipation
. To prevent collisions in the$_POST
global I’ve prefixed these withmy_
(feel free to change this). So in themy_save_venue_meta()
callback you can retrieve the “open” value from$_POST['my_open']
and the participation array by$_POST['my_participation']
To display these details on the event page, simple edit the
event-meta-event-single.php
and include the following:<?php $open = eo_get_venue_meta( eo_get_venue(), 'open' ,true ); if( $open ){ //Is open }else{ //Not open } $participation = eo_get_venue_meta( eo_get_venue(), 'participation' ,true ); echo 'Participation: '. implode( ', ', $participation ); //Prints e.g. Participation: 2010, 2013 ?>
Stephen Harris
March 10, 2015 at 12:05 am #15449Thank you a lot for the great support. I’ve made the change today and the venue has now all the datas I need. Radio, checkbox and datepicker, it all worked like a charm!
BTW, it would be a great feature to be able to select venue by custom field, in the venue map shortcode 😉
-
This reply was modified 10 years ago by
José Morin.
José Morin
-
This topic was modified 10 years, 3 months ago by
-
AuthorPosts