Jump to content

WP Events list ordering


dangermoose

Recommended Posts

Hi all, Im new to php but enjoying the learning curve and also getting to know my way around WordPress. I am building a page to list events and came across a great tutorial http://www.problogdesign.com/wordpress/how-to-make-a-wordpress-events-list.

 

I cannot manage to get it to work with my themes php though, it kind of works and does list the events but doesnt pull in the images assigned to each event (post). I also lost the 'next' and 'previous' buttons at the bottom of the page for some reason. I thoguth it had something to do with the

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

, maybe was in the wrong place but not so sure. Is there anything very obvious (Im sure there is!) I'm missing bearing in mind all I have added is the code from that url...

 

            <?php the_content(); ?>
          </div>
        </div>
        

        <?php //not sure about this? It was originally - while (have_posts()) : the_post();
         if (have_posts()) : while (have_posts()) : the_post(); ?>

        <div class="grid_4a alpha portfolio-box-events">
          <div class="gallery clearfix" style="width:220px;"><br/>          
            <?php	$img=get_post_meta($post->ID, 'Image', true); 
			$timthumboption = get_option("timthumboption"); ?>
            <?php if($img) { ?>
            <?php if( $timthumboption == "0" ){?>
            <a href="<?php echo $img; ?>" rel="prettyPhoto[gallery2]"> <img src="<?php bloginfo('template_url'); ?>/timthumb.php?src=<?php echo $img; ?>			
		&w=204&h=104&zc=2" alt="<?php the_title(); ?>"  class="thumbnail-border"/> </a>
            <?php } ?>
            <div style="position:relative; float:left; width:700px;">
              <div style="width:204px; position:relative; float:left;">
                <?php	if( $timthumboption == "1" ){?>
                <a href="<?php echo $img; ?>" rel="prettyPhoto[gallery2]"><img src="<?php echo $img; ?>" width="204" alt="<?php the_title(); ?>" class="thumbnail-border"/></a>
                <?php } }?>
              </div>
              
              <?php // Get today's date in the right format
$todaysDate = date('m/d/Y H:i:s');?>

              <?php query_posts('showposts=10&category_name=festival&meta_key=Date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC'); ?>
              
              <div style="width:450px; position:relative; float:left; margin-left:20px;">
                
                <h3><a href="<?php the_permalink(); ?>">
                  <?php the_title(); ?>
                  </a></h3>
                <p>
                  <?php the_content(); ?>
                </p>
                <a href="<?php the_permalink() ?>" class="view-more2"><strong>View More</strong></a>
                <?php endwhile; else: ?>
                Sorry, no upcoming events!
                <?php endif; ?>
                <?php wp_reset_query(); ?>
              </div>
            </div>

          </div>
        </div>
      </div>
      <?php endwhile; ?>
      <div class="clear"> </div>
      <div class="navigation">
        <div class="alignright">
          <?php next_posts_link('Next Page »') ?>
        </div>
        <div class="alignleft">
          <?php previous_posts_link('« Previous Page') ?>
        </div>
      </div>
        </div>
    <!--End Right Section -->
  </div>
</div>
</div>
<!--End middle content Section -->
<?php get_footer(); ?>

Link to comment
Share on other sites

I've kind of got it working now. It display's the list in the correct order but the functionality of the 'next' and 'previous' buttons at the bottom of the page is broken, it basically loads the same posts again when clicking 'next'...

 

This is the line of code that i edited:

 

query_posts('cat=$portfoliopages.&paged=&showposts=20&category_name=festival&meta_key=Date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC'); 

 

I think there may be a conflict between 'cat=$portfoliopages' & the code I added in that line but not sure how to fix. Any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.