• Resolved MP

    (@therealmikep)


    I’m trying to display custom HTML on a single event page.

    Using Tribe’s example to debug, just trying to output <button>Button</button> after each event’s description. I’m hoping to avoid duplicating the template files but rather to insert using a hook.

    Here’s what I have:

    add_action( 'tribe_template_after_include:events/single-event/content', function( $file, $name, $template ) {
      echo '<button>Button</button>';
    }, 10, 3 );

    Is this the correct slug events/single-event/content?

    Or if I wanted to output the html after the title I would use this:

    add_action( 'tribe_template_after_include:events/single-event/title', function( $file, $name, $template ) {
      echo '<button>Button</button>';
    }, 10, 3 );

    Neither show output on single event pages.

    Am I misunderstanding the slug structure? Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Gustavo Bordoni

    (@bordoni)

    Hi @therealmikep,

    Ohh I see what you mean, the problem might be related to which editor you are using. Try switching from Classic to Blocks editor to see if the problem gets resolved.

    Hopefully this problem is resolved by now, but if not please let me know and I will remove the “Resolved” tag from the topic.

    Best Regards,

    Hi there,

    For adding content after the event description, there’s a hook called tribe_events_single_event_after_the_content that should work for your purposes.

    For example:

    function tec_insert_button_after_description() {
    	echo '<button>I am a custom button</button>';
    }
    add_action( 'tribe_events_single_event_after_the_content', 'tec_insert_button_after_description' );

    Am I misunderstanding the slug structure?

    Yes, there appears to be a misunderstanding. This is not for inserting arbitrary code within a template.

    You can take a look at the wp-content/plugins/the-events-calendar/src/views/single-event.php file to see what other hooks are available for doing that. They will be wrapped in a do_action function.

    For example, see what you can do with the tribe_events_single_event_before_the_meta hook.

    Hope this helps point you in the right direction and best of luck.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Customize views – hooks not firing? (e.g. tribe_template_after_include)’ is closed to new replies.