Home › Forums › Welcome! › Pre-Sales Questions › Hooks running before \'functions.php\'
- This topic has 4 replies, 2 voices, and was last updated 7 years, 12 months ago by
Support Droid.
-
AuthorPosts
-
April 23, 2018 at 4:39 am #1513536
Luca
ParticipantHey guys, I tried to add some php-code to the single-event-view.
I added an action to the hook ‘tribe_events_after_the_meta’ in my functions.php file.
But nothing is happening. If I call the action in the functions.php directly, it works! (On the wrong position, of course.)So my guess is that the hook from the plugin fires before the “add_action” in my functions.php. I could be wrong, but still…
Does anyone has an idea whats wrong?
add_action( 'tribe_events_after_the_meta', 'addmycode' ); function addmycode() { echo "Hello world!"; }April 24, 2018 at 9:49 am #1515012Cliff
MemberHi, Luca.
Please reference https://theeventscalendar.com/knowledgebase/implementing-custom-code-snippets/ for how to implement custom code snippets.
Please let me know how this goes for you.
April 24, 2018 at 11:20 pm #1515480Luca
ParticipantI’ve checked ALL of the tips in the article, nothing is wrong with anything mentioned there.
What confuses me is, if I run the hook myself via do_action directly after my code on the functions.php it works perfectly as intended. But, as I mentioned earlier, on the wrong position.
So I guess my code is not the problem. I just need to get my code running before the plugin code, maybe?
April 25, 2018 at 2:15 am #1515533Luca
ParticipantOk I managed it in a different way:
add_action( 'loop_start', 'tribe_events_insertion' ); // Could also be "loop_end" for code AFTER the event function tribe_events_insertion() { if ( get_post_type( get_the_ID() ) == 'tribe_events' ) { // Extra Code } }… if anyone else ever needs this …
April 26, 2018 at 12:13 pm #1517210Cliff
MemberThat hook is used in more than our own plugins — https://developer.wordpress.org/reference/hooks/loop_start/ — therefore, it’s likely not the ideal choice.
Depending on what you’re trying to implement, you might be interested in using https://theeventscalendar.com/extensions/calendar-widget-areas/ — or at least reference its logic for which hook(s) to leverage.
Another idea is to try https://wordpress.org/plugins/simply-show-hooks/ (third-party, not guaranteed or supported by us) to visually indicate where various hooks fire.
Please let me know if you make any further progress for your needs.
May 18, 2018 at 9:35 am #1533933Support 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 ‘Hooks running before \'functions.php\'’ is closed to new replies.
