Support » Plugin: The Events Calendar » How to display the Event Title?

  • Hey Guys,

    this question seems pretty simple, but i cant find any solution. i am working on a page with a custom template. so now i want to use the event title – i am on a single event page – as the headline of the page in my index.php (this is important). the <h1> is not in the loop. the code looks something like this (simplified)

    index.php

    <header>
    <h1>### HEADLINE ###</h1>
    </header>
    
    -- loop --

    do you know how to get the event title?

    thanks in advance
    Kevin

    • This topic was modified 11 months, 1 week ago by pixelfeinkost.
Viewing 1 replies (of 1 total)
  • there are some more informations for you.

    in the index.php:

    <!doctype html>
    <html lang="de">
        <head>
            [...]
            <?php wp_head(); ?>
        </head>
        <body>
            <header>
                <div class="title">
                    <?php
                        if( is_singular( 'tribe_events' ) ) {
                            // we are on a single event page
                            ?>
                               <h1>HELP! how to get the event name?</h1>
                            <?php
                        } else {
                            // we are not on an single event page
                            ?>
                               <h1>other headline - doesnt matter</h1>
                            <?php
                        }
                    ?>
                </div>
            </header>
    
            <?php
                if ( have_posts() ) {
                    // Load posts loop.
                    while ( have_posts() ) {
                        the_post();
                        the_content();
                    }
                }
            ?>
            <?php wp_footer(); ?>
        </body>
    </html>

    i display the content of the event overview and the single event details via “the_content()” .. so, technically i’m in the index.php without a page in the background. that’s the reason why i get a 0 when i var_dump the get_the_id() value. i think this might be the reason why i get a NULL for get_the_title(). but how do i get the information instead? when i use get_the_title() in the loop, im not getting the title either, so this must be an other issue. im clueless.

    • This reply was modified 11 months, 1 week ago by pixelfeinkost.
Viewing 1 replies (of 1 total)
  • The topic ‘How to display the Event Title?’ is closed to new replies.