-
-
Save cliffordp/3584b8aee70cde484700 to your computer and use it in GitHub Desktop.
<?php | |
/** | |
* The Events Calendar: Open event website, organizer, and venue links in new window. | |
* | |
* Filters are found in these files: | |
* /wp-content/plugins/the-events-calendar/src/functions/template-tags/link.php | |
* /wp-content/plugins/events-calendar-pro/src/functions/template-tags/general.php | |
* /wp-content/plugins/the-events-calendar/src/functions/template-tags/organizer.php | |
* /wp-content/plugins/the-events-calendar/src/functions/template-tags/venue.php | |
* | |
* @link https://gist.github.com/cliffordp/3584b8aee70cde484700 | |
* | |
* @return string | |
*/ | |
add_filter( 'tribe_get_event_website_link_target', 'cliff_blank_target_for_new_window' ); | |
add_filter( 'tribe_get_organizer_website_link_target', 'cliff_blank_target_for_new_window' ); | |
add_filter( 'tribe_get_venue_website_link_target', 'cliff_blank_target_for_new_window' ); | |
function cliff_blank_target_for_new_window() { | |
return '_blank'; | |
} |
Hi CliffordP, Can you explain why your name is in the code?
Hi. I put my name in my snippets as a way to namespace them. If I were to name them generically like 'remove_link', it would be ripe for conflicts. Snippets are to be reviewed/customized.
Please reference https://theeventscalendar.com/knowledgebase/k/best-practices-for-implementing-custom-code-snippets/ for how/where to install them.
Just rename them yourself when you install them :)
This does not work for the organizer link (at least not as of right now). According to
/wp-content/plugins/the-events-calendar/src/functions/template-tags/organizer.php
it is 'tribe_get_event_organizer_link_target'
instead of 'tribe_get_organizer_website_link_target'
For those wondering where to put this code:
Put it in the functions.php of your theme. To avoid it being overwritten by theme updates create a child theme, see: https://developer.wordpress.org/themes/advanced-topics/child-themes/
There are also several wordpress plugins which allow you to add code simply via the wp dashboard.
Thanks for sharing.
Those tips are part of that Knowledgebase article :)
Thanks, still works!
Hi CliffordP. Can you please explain how to use this code. To I just place it in the functions file?
Also why does it contain your name in the code "cliff_blank...."?