• Amazing plugin, works great and has been a charm to fiddle with.

    I’ve successfully added a custom field to events — a country field for our international tours — and a custom link, following the “more info” button thread on here.

    I’m struggling to combine the two however, what I need is a second link, functioning the same as the ticket link, but allowing a link to the social page, usually a Facebook event. The more info link currently is just the permalink.

    Any tips appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mikebravostudio

    (@marcussunday)

    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…

    Thread Starter mikebravostudio

    (@marcussunday)

    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);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom link?’ is closed to new replies.