• Resolved hynek

    (@hynek)


    Hi,

    I am sorry I am just beginner so it is totally stupid question. However I can’t type event loop code on my own. Is there any template of the code similiar to the normal one? Like this one:

    <?php query_posts('cat=2&posts_per_page=1'); ?>
                    <?php if (have_posts()) : ?>
                    <?php while (have_posts()) : the_post(); ?>
                    <div class="featurette-image img-square img-responsive pull-right"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array(670,2000) ); ?></a></div>
                 <p>
        <?php the_content( ); ?>
        <?php endwhile; ?>
        <?php endif; ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]

    I don’t know what should I change it to make it works in the same way but for Events. Thank you very much.

    https://wordpress.org/plugins/the-events-calendar/

Viewing 1 replies (of 1 total)
  • Hi @hynek,

    Thanks for stopping by! No apologies needed–there are no stupid questions on this forum! I’d be glad to help you out here! 🙂

    For a custom loop that’s pulling events instead of regular WordPress posts, I’d recommend using WP_Query instead of query_posts()–you’ll find plenty of information on how to use this class at the link above, including a basic loop that you can modify for your purposes. The $args argument that’s passed at the beginning of the loop is where you’ll want to specify the events custom post type, like so:

    $args = array(
         'post_type' => 'tribe_events'
    );
    $the_query = new WP_Query( $args );

    Any other arguments you’d like to include can be added to $args in the same way. The WP_Query page goes into plenty of detail and is worth saving for future reference should you ever need to create custom loops!

    I hope that helps to get you started! Best of luck, and let us know if you should have any other questions!

Viewing 1 replies (of 1 total)

The topic ‘How to make event loop?’ is closed to new replies.