Need Help with Custom Wordpress Loops...

I have a wordpress site that is running the no future posts plugin so that all post will show up as published. I do this so the site viewers can use the calendar to browse future events. On the home page I am trying to show all post that happen on or before the current date and list them starting with today's date. One the events page I am only showing upcoming posts in the events category to simulate an upcoming events page. I also have an upcoming events and recent posts list in the sidebar. The url to the website I'm working on is http://www.keepfaithmoving.org

I thought I had all the code right but it seems that when we kept adding posts it started to mess up and now it is acting weird. Any help discovering the issue would be very helpful. I will post the code I am using on those pages.

 
index-loop.php
-------------------

<?php $my_query = new WP_Query("category_name=events,audio,video,articles&order=DESC");
    if ($my_query->have_posts()) {
        $i = 0;
        while ($my_query->have_posts() && $i < 100 ) : $my_query->the_post(); $do_not_duplicate = $post->ID;
    if (get_the_time('Ymd') <= date('Ymd')) : $i++; ?>
       
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
			<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

			<div class="entry-meta">
				<?php twentyten_posted_on(); ?>
			</div><!-- .entry-meta -->

	<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
			<div class="entry-summary">
				<?php the_excerpt(); ?>
			</div><!-- .entry-summary -->
	<?php else : ?>
    
    <div class="entry-content">
<?php the_content('Read the rest of this entry &raquo;'); ?>
</div>
	
   <!-- .entry-content -->
	<?php endif; ?>

			<div class="entry-utility">
            <?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php comments_popup_link('Leave a Comment', '1 Comment ', '% Comments'); ?> <?php edit_post_link( __( 'Edit', 'twentyten' ),  '</span>' ); ?>
          <!--  <br />
				<?php if ( count( get_the_category() ) ) : ?>
					<span class="cat-links">
						<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
					</span>
					<span class="meta-sep">|</span>
				<?php endif; ?>
				<?php
					$tags_list = get_the_tag_list( '', ', ' );
					if ( $tags_list ):
				?>
					<span class="tag-links">
						<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
					</span>
					<span class="meta-sep">|</span>
				<?php endif; ?>
				<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
				<span class="meta-sep">|</span><span class="edit-link"><?php edit_post_link( __( 'Edit', 'twentyten' ),  '</span>' ); ?>-->
				</div><!-- .entry-utility -->
		</div><!-- #post-## -->

<?php endif; endwhile; } ?>

Open in new window

events.php
-----------------
<?php
$my_query = new WP_Query('category_name=events&post_status=publish&order=ASC');
?>

<?php
if ($my_query->have_posts()) : while ($my_query->have_posts()) :
$my_query->the_post();
$do_not_duplicate = $post->ID;
    if (get_the_time('Ymd') >= date('Ymd')) : $i++; ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
			<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

			<div class="entry-meta">
				<?php twentyten_posted_on(); ?>
			</div><!-- .entry-meta -->

	<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
			<div class="entry-summary">
				<?php the_excerpt(); ?>
			</div><!-- .entry-summary -->
	<?php else : ?>
    
    <div class="entry-content">
<?php the_content('Read the rest of this entry &raquo;'); ?>

</div>
	
   <!-- .entry-content -->
	<?php endif; ?>

			<div class="entry-utility">
            <?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php comments_popup_link('Leave a Comment', '1 Comment ', '% Comments'); ?> <?php edit_post_link( __( 'Edit', 'twentyten' ),  '</span>' ); ?>
          <!--  <br />
				<?php if ( count( get_the_category() ) ) : ?>
					<span class="cat-links">
						<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
					</span>
					<span class="meta-sep">|</span>
				<?php endif; ?>
				<?php
					$tags_list = get_the_tag_list( '', ', ' );
					if ( $tags_list ):
				?>
					<span class="tag-links">
						<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
					</span>
					<span class="meta-sep">|</span>
				<?php endif; ?>
				<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
				<span class="meta-sep">|</span><span class="edit-link"><?php edit_post_link( __( 'Edit', 'twentyten' ),  '</span>' ); ?>-->
                
<!--                <?php
echo 'comment count is: ' . $post->comment_count;
 // Restore global post data stomped by the_post().
?>
-->
				</div><!-- .entry-utility -->
              



		</div><!-- #post-## -->
<?php endif; endwhile;?>

 
<?php endif; ?></div>

Open in new window

sidebar.php
---------------

<div id= "eventbx"><span class="event_heading">UPCOMING EVENTS</span>
<ul style="list-style-type:none;padding: 0;margin-left: 0;">
<?php
$my_query = new WP_Query('category_name=events&post_status=publish&order=ASC&showposts=5');
?>

<?php
if ($my_query->have_posts()) : while ($my_query->have_posts()) :
$my_query->the_post();
$do_not_duplicate = $post->ID;
    if (get_the_time('Ymd') >= date('Ymd')) : $i++; ?>
 
<li> <?php the_time('n/j')?>&nbsp;-&nbsp;<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permalink to <?php the_title(); ?>"><?php the_title(); ?></a></li>
 
<?php endif; endwhile;?>

 
<?php endif; ?>
</ul></div>


<div style="height:30px;clear:both;"></div>

<div id= "eventbx"><span class="event_heading">RECENT POSTS</span>
<ul style="list-style-type:none;padding: 0;margin-left: 0;">
<?php
$my_query = new WP_Query('category_name=articles,video,audio&post_status=publish&order=DESC&showposts=5');
?>

<?php
if ($my_query->have_posts()) : while ($my_query->have_posts()) :
$my_query->the_post();
$do_not_duplicate = $post->ID;
    if (get_the_time('Ymd') <= date('Ymd')) : $i++; ?>
 
<li><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permalink to <?php the_title(); ?>"><?php the_title(); ?></a></li>
 
<?php endif; endwhile;?>

 
<?php endif; ?>
</ul></div>

Open in new window


If anyone could point out my mistakes and help me work this kink out , that would really help me on this project. Thank you!
merchantweb2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

merchantweb2Author Commented:
anyone?
0
gwkgCommented:
Do you have a link to an example of where "it started to mess up and now it is acting weird"?
0
merchantweb2Author Commented:
Here is my test server where I thought it was all working but that was before I added more posts.: http://secundsun.com/wordpress3

Ok, the home page should be showing the 5 latest posts under the welcome message. These would be the same 5 posts that appear under recent posts in the sidebar. Also, the upcoming events in the sidebar should show the next 5 upcoming events.

On keepfaithmoving.org we have added many more events and posts but it seems to not display correctly, the more posts we add.

Right now if you go to keepfaithmoving.org, none of the upcoming events are displaying under the sidebar section for events, yet on the events page you will see that there are 6 future events.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

merchantweb2Author Commented:
???
0
gwkgCommented:
Did you get the upcoming events fixed because when I go to your events page I see the the same future events listed in both the posts and the sidebar.

http://keepfaithmoving.org/?page_id=13

And the recent posts in the sidebar appears to be working correctly too.  The most recent posts that aren't events are listed.
0
gwkgCommented:
If you are trying to exclude the category "events" from the posts under the welcome message so that they match your 'Recents Posts' list in the sidebar then make your query $args the same

in index-loop.php you have category_name=events,audio,video,articles

but in sidebar.php you have category_name=articles,video,audio

0
merchantweb2Author Commented:
Hi, thanks for coming back to this one. I was able to get the sidebar upcoming events list to work by changing the code to the following:


 
<?php $my_query = new WP_Query("category_name=events&order=ASC");
    if ($my_query->have_posts()) {
        $i = 0;
        while ($my_query->have_posts() && $i < 5 ) : $my_query->the_post(); $do_not_duplicate = $post->ID;
    if (get_the_time('Ymd') >= date('Ymd')) : $i++; ?>
       <li> <?php the_time('n/j')?>&nbsp;-&nbsp;<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permalink to <?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endif; endwhile; } ?>

Open in new window


I wanted the posts that show under the welcome message to show all posts on the site, like a latest news and events list. I am still having problems getting that to work. It should show the latest 5
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason C. LevineNo oneCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.