Home › Forums › Calendar Products › Events Calendar PRO › Redirecting Links in Calendar – Code Snippet Goes Where?
- This topic has 4 replies, 2 voices, and was last updated 7 years, 6 months ago by
skywing.
-
AuthorPosts
-
September 5, 2018 at 5:07 pm #1614764
skywing
ParticipantI have Events Calendar PRO and am curious to if it’s possible to redirect various links on pages dedicated to specific events. For instance, above the title of an event there is a way to go back to ‘All Events’, however it directs users to the primary page that the event calendar URL is, but I’d prefer it to go to another page on my website. Is there a way to do this?
I received this code snippet as an answer to this question, but I’m not sure where to insert it so as to get it to work. Anyone able to help?
<?php
/**
* The Events Calendar: Turn the “All Events” link into a true “Back” button.
*
* Generally not advisable but provided at customer’s request:
* https://theeventscalendar.com/support/forums/topic/upcoming-events-8/
*
* @link https://gist.github.com/cliffordp/60b5acf003fa68ad7803313d662c08e7
* @link https://css-tricks.com/snippets/javascript/go-back-button/
* @link https://api.jquery.com/replacewith/
*/
add_action( ‘wp_footer’, ‘cliff_all_events_link_replaced_with_back_button’ );
function cliff_all_events_link_replaced_with_back_button() {
wp_enqueue_script( ‘jquery’ );
?>
<script type=”text/javascript”>
jQuery( document ).ready( function () {
var all_events = jQuery( ‘p.tribe-events-back a’ );
// The following line is commented out because an “All Events” link that goes back to say the Blog Posts page would confuse the user.
// var button_text = all_events.text().trim();
var button_text = ‘« Go Back’;
var new_element = ‘<input type=”button” value=”‘;
new_element += button_text;
new_element += ‘” onclick=”history.back(-1)” />’;
all_events.replaceWith( new_element );
} );
</script>
<?phpSeptember 6, 2018 at 1:56 pm #1615700Barry
MemberHi!
This could be added either to a custom plugin (preferred) or else to your theme’s functions.php file.
Many people find the latter to be easiest, however using a custom plugin is arguably the safer approach (plus, it makes it easy to turn this functionality off again in the future, because you can simply deactivate the plugin).
Does that help at all?
September 6, 2018 at 7:08 pm #1615858skywing
ParticipantThis code should be for Events Calendar PRO though… does Events Calendar PRO not have a space where I can add custom code?
September 6, 2018 at 7:51 pm #1615878skywing
ParticipantAlso, would I be putting this under The Events Calendar Pro Plugin or the regular Events Calendar Plugin?
September 7, 2018 at 8:06 am #1616232Barry
MemberHi!
Modifying plugins like The Events Calendar or Events Calendar PRO directly is generally not a great idea: your changes would be lost when you next update and it would potentially make it harder for us to assist you in the future.
For those reasons, adding the code to a custom plugin is the best and safest approach though, as noted, it’s also a common practice and many people find it easier to add code to their theme (or child theme’s) functions.php file.
There are also various plugins out there you can use to add PHP code visually, through the dashboard. I don’t have any particular recommendations to make in that direction – but they could be another option for you 🙂
I hope that helps!
September 29, 2018 at 9:35 am #1633778Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Redirecting Links in Calendar – Code Snippet Goes Where?’ is closed to new replies.
