Home › Forums › Calendar Products › Events Calendar PRO › Creating a Button/Text Link for a Custom Field
- This topic has 4 replies, 3 voices, and was last updated 10 years, 8 months ago by
Support Droid.
-
AuthorPosts
-
August 10, 2015 at 10:46 am #994815
Heather Wood
ParticipantHi, I noticed this article which is cool and tells me how to create a text link from the website URL
https://theeventscalendar.com/knowledgebase/url-as-word-button/My question is, I created a custom field URL named Syllabus. How would I know what the filer is called so I can modify this code to do the same thing, but for my custom field?
//Create button from Syllabus in The events calander
add_filter(‘tribe_get_event_website_link_label’, ‘tribe_get_event_website_link_label_default’);function tribe_get_event_website_link_label_default ($label) {
if( $label == tribe_get_event_website_url() ) {
$label = “Visit Website »”;
}return ‘‘ . $label . ‘ ‘;
}August 10, 2015 at 11:23 am #994831George
ParticipantSorry Heather, we unfortunately don’t offer support for custom code here on the forums so I will have to close up this thread pretty soon…
…However, just to try and shed some light on things before closing the thread, if you’re using a separate custom field that you’re trying to display there, then you will need to use the WordPress function get_post_meta() and call that field directly, not just use the tribe_get_event_website_url() function.
An alternative to all of this is to use an Events Calendar Pro “Additional Field” to store that Syllabus information, and you can then quite easily get this to show in that event meta section. You can learn about this alternative method here → https://theeventscalendar.com/knowledgebase/pro-additional-fields/
Cheers,
GeorgeAugust 10, 2015 at 11:45 am #994841Heather Wood
Participantthat’s actually exactly what I’m asking.
I already created my custom field using this method
so how would I know what the filter is? by using the get method?
what is generated when I create the field…?August 11, 2015 at 11:54 am #995204George
ParticipantHey Heather,
Awesome, in that case then yes retrieving the data is as simple as using a function called tribe_get_custom_fields().
If your custom field’s name is just “Syllabus”, for example, then code like this would work to echo the value of that field for a given event:
$custom_fields = tribe_get_custom_fields();echo $custom_fields['syllabus'];
So, the original code example you posted was this:
add_filter('tribe_get_event_website_link_label', 'tribe_get_event_website_link_label_default');function tribe_get_event_website_link_label_default ($label) {
if( $label == tribe_get_event_website_url() ) {
$label = "Visit Website »";
}return '' . $label . ' ';
}
And example of reworking that to use the new field is this:
add_filter('tribe_get_event_website_link_label', 'tribe_get_event_website_link_label_default');function tribe_get_event_website_link_label_default ($label) {
$custom_fields = tribe_get_custom_fields();
if( isset( $custom_fields['syllabus'] ) && $label == $custom_fields['syllabus'] ) {
$label = "Visit Website »";
}return '' . $label . ' ';
}
That should help – we unfortunately can’t provide much more code-level support than snippets like this, but play around with things a bit and let us know if it helps.
Best of luck with your customizing,
GeorgeAugust 26, 2015 at 7:05 am #999124Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Creating a Button/Text Link for a Custom Field’ is closed to new replies.
