0

I'm trying to query some fields from a custom post-type created by "The Events Calendar" plugin, in my footer.php. The post-type is called 'tribe_events'. Here's my query, which is currently showing me nothing.

                    <ul class="evul" >
                        <?
                        $query = new WP_Query
                       ( array( 'post_type' => 'tribe_events') );
                        if ($query->have_posts() ) 
                        : while ($query-> have_posts()) :
                         $query->the_post();
                        ?>

                     <li class="evlist" id="evli-">
                    <span class="evdate" id="evspd-">
                        <?  echo tribe_get_venue();?>
                    </span>
                    <span class="evtype" id="evspt-">
                        <? echo tribe_get_events_link(); ?>:
                    </span>
                    <span class="evdesc" id="evspds-">
                        <? echo the_title(); ?>
                    </span>
                       </li><br>

 <?  endwhile; endif; wp_reset_postdata(); 
 ?>

                    </ul>

                </div>

I'm not sure what else I need to do. Is there a step I'm missing since it's from a plugin?

Thank you.

2
0

Your approach should work I think, I would check only if short PHP open tags <? are working in your server configuration because they are deprecated for some time and should be replaced with <?PHP.

Alternatively have you tried the approach from the plugin's docs using the build in function tribe_get_events():

<ul class="evul" >
<?PHP
// Ensure the global $post variable is in scope
global $post;

$events = tribe_get_events();

// Loop through the events: set up each one as
// the current post then use template tags to
// display the title and content
foreach ( $events as $post ) {
    setup_postdata( $post );

    // This time, let's throw in an event-specific
    // template tag to show the date after the title!
    ?>
    <li class="evlist" id="evli-">
        <span class="evdate" id="evspd-">
            <?= tribe_get_venue($post) ?>
        </span>
        <span class="evtype" id="evspt-">
            <?= tribe_get_events_link($post) ?>:
        </span>
        <span class="evdesc" id="evspds-">
            <?= get_the_title($post); ?>
        </span>
    </li>
    <?PHP
}
?>
</ul>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.