• Resolved Chetan Prajapati

    (@chetan200891)


    Hi,

    I am looking for custom query to get all events sort by event date and posts per page with pagination. I tried query_posts but it does not working.

    Can you please help me?

    Thanks,
    Chetan

Viewing 2 replies - 1 through 2 (of 2 total)
  • Barry

    (@barryhughes-1)

    Hi @chetan200891!

    Custom dev work isn’t something we can generally assist with here (in fairness to our paying customers, we really need to prioritize our premium forums which are currently experiencing high levels of demand).

    I’m sure other community users may be able to share advice, though, and if you search these forums and our Events Calendar PRO forums you’ll probably find some useful code ??

    Do also check out the following function:

    tribe_get_events()

    Good luck with your project!

    <?php
    				global $post;
    				$post->ID;
    				$today = date( 'Y-m-d H:i:s');
                    $tribe_events_post_type = 'tribe_events';
                    $tribe_events_post_paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                    $tribe_events_post_args = array( 
                        'post_type'        => $tribe_events_post_type,
                        'post_status'      => 'publish',
                        'posts_per_page'   => 2, 
                        'paged' 		   => $tribe_events_post_paged,
                        'caller_get_posts' => -1,
    					/*'meta_query' => array(
    					array(
    						'key' => '_EventStartDate',
    						'value' => $today,
    						'compare' => '>=',
    						)
    					),*/
    					'orderby'=>'_EventStartDate',
                        'order'            => 'DESC'
                    );
                    $tribe_events_postloop = new WP_Query( $tribe_events_post_args );
                    if( $tribe_events_postloop->have_posts() ) 
                    {
                        while ( $tribe_events_postloop->have_posts() ) : $tribe_events_postloop->the_post();
                         $business_title = get_the_title();
                        ?>
                                 <h3><?php echo get_the_title();?></h3>
                                 <br />
                                  <?php if (tribe_get_start_date() !== tribe_get_end_date() ) { ?>
    								<?php echo tribe_get_start_date(); ?> - <?php echo tribe_get_end_date(); ?>
                                  <?php } else { ?>
                                    <?php echo tribe_get_start_date(); ?>
                                <?php } ?>
                                <br />
                                <?php echo get_the_content();?>
                                <hr/>
                       <?php
                         endwhile;
                        ?>
                        <?php 
                    }
                    wp_reset_query();  // Restore global post data stomped by the_post().
                ?>
                <?php 
                if(function_exists('wp_pagenavi')) 
                { 
                    echo wp_pagenavi( array( 'query' => $tribe_events_postloop ) );
                
                }
                ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Query to get all events’ is closed to new replies.