WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] how to list events in a grid (9 posts)

  1. darksigns
    Member
    Posted 10 months ago #

    Hi all,

    I wrote a simple code to list events in 2 column grid but I miss something, there is nothing placed in my second column just in the first.
    here is my content-grid template code:

    <?php
    $args = array(	'post_type' => 'event',
    				'posts_per_page' => 10,
    				'meta_query' => array(
    					array( 'key' => '_start_ts', 'value' => current_time('timestamp'), 'compare' => '>=', 'type'=>'numeric' )),
    				'orderby' => 'event_start_date',
    				'order' => 'DESC'
     				 );
    $loop = new WP_Query( $args );
    $num_cols = 2; // set the number of columns here
    for ( $i=1 ; $i <= $num_cols; $i++ ) :
    echo '<div id="col-' . $i . '" class="col" >';
    $counter = $num_cols + 1 - $i;
    	while ( $loop->have_posts() ) : $loop->the_post();
    		if( $counter%$num_cols == 0 ) :
    		// begin of core posts output ?>
    		<strong><?php echo EM_Events::output( $args );?></strong>
           		<?php endif; $counter++; endwhile;?>
    		<?php rewind_posts();
    echo'</div>'; endfor; ?>
        <?php if (  $wp_query->max_num_pages > 1 ) : ?>
    	<div id="nav-below" class="navigation">
    		<?php if(function_exists('page_navi')) { page_navi(); } else { ?>
    		<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
    		<?php } ?>
            </div><!-- #nav-below -->
    	<?php endif;?>
    <?php wp_reset_query(); ?>

    any ideas?

    thank you

    http://wordpress.org/extend/plugins/events-manager/

  2. darksigns
    Member
    Posted 10 months ago #

    An update: sorry but I wrote wrong both columns has the same content !

  3. darksigns
    Member
    Posted 10 months ago #

    Update:

    I made my code as simple as I could, to find out the error,
    when using this as my page 1 have 1 event saved on my site and this silly code prints that event 2 times in each column.

    <?php
    global $post ;
    $args = array('post_type' => 'event');
    $loop = get_posts( $args );
    $num_cols = 2; // set the number of columns here
    for ( $i=1 ; $i <= $num_cols; $i++ ) :
    echo '<div id="col-' . $i . '" class="col" >';
    $counter = $num_cols + 1 - $i;
    foreach ( $loop as $post):
    		if( $counter%$num_cols == 0 ) :
    		// begin of core posts output
    			em_events( $args );
    		endif; $counter++;
    endforeach;
    echo'</div>'; endfor;
    ?>

    please somebody help meeee..

  4. caimin_nwl
    NetWebLogic Support
    Posted 10 months ago #

    I may be missing something but since you've set $num_cols = 2, you're forcing the code to run twice.

  5. darksigns
    Member
    Posted 10 months ago #

    hm,

    if I put inside the the_content() it runs well and shows the correct things but everything with the maps and so on
    but when i use it with the include'events-lsit.php it runs 3 times:)
    ok than how can I do it?

    I am lost
    THX

  6. angelo
    NetWebLogic Support
    Posted 10 months ago #

    hi,

    don't know if this will help you since I haven't tried this but I think you can create something similar with this http://stackoverflow.com/questions/15457089/creating-a-grid-view-of-products-in-php

  7. darksigns
    Member
    Posted 10 months ago #

    thanx in the meantime I solved it with css !

  8. pierrem7@gmail.com
    Member
    Posted 10 months ago #

    Please help me I' trying to create a page that can be accessible via main menu and that displays all scheduled events in either a calendar or ideally in a categorized list ( by type and date...

    NOT in the widget area!

  9. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 9 months ago #

    @pierrem7 pls open a new thread

Reply

You must log in to post.

About this Plugin

About this Topic