So I’ve got adding custom fields sorted I *think*
// event facebook
function wpt_event_editor_add_event_social_field($fields) {
$new_fields = array();
foreach($fields as $field) {
$new_fields[] = $field;
if ('remark' == $field['id']) {
$new_fields[] = array(
'id' => 'event_social',
'title' => 'Social Link',
'edit' => array(
'placeholder' => 'https://www.facebook.com/events/0000000000',
),
);
}
}
return $new_fields;
}
add_filter( 'wpt/event_editor/fields', 'wpt_event_editor_add_event_social_field');
— I just need to try and manipulate the “more info” button code into making the above work as a link, eg: the frontend displays the word “social” and links to the uploaded link…
So… (!)
This link makes light work of adding a new field and a URL.
If I try and amend that, I can’t replicate the behaviour, and can’t work out what I’m missing!
// social url field
function wpt_event_editor_add_social_url_field($fields) {
$new_fields = array();
foreach($fields as $field) {
$new_fields[] = $field;
if ('remark' == $field['id']) {
$new_fields[] = array(
'id' => 'social_url',
'title' => 'Social',
'edit' => array(
'placeholder' => 'https://www.facebook.com/events/00000000000/',
),
);
}
}
return $new_fields;
}
add_filter( 'wpt/event_editor/fields', 'wpt_event_editor_add_social_url_field');
// link to social url
function wpt_event_add_social_url($html, $event) {
$social_url = $event->custom('social_url');
if (!empty($social_url)) {
$html = '<a href="'.esc_attr($social_url).'" target="_blank" style="display: block;">'.$html.'</a>';
}
return $html;
}
add_filter( 'wpt_event_location_html', 'wpt_event_add_social_url', 10, 2);