WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Eleven
[resolved] Archive Page is under infinite loop (6 posts)

  1. Kelvin Castelino
    Member
    Posted 1 year ago #

    My site: http://cfci.org.in/2007/09/ archive page is going in an infinite loop! Why is that so? Whats wrong!
    The site is gone live, so would need urgent help please :( :(

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    please post the full codes of archive.php and content.php

    does this also happen if you switch to an unedited Twenty Eleven, and with all plugins deactivated?

  3. Kelvin Castelino
    Member
    Posted 1 year ago #

    Here's the whole scene!
    At first my page used to not load with an Unkown Error with something to do with parsing! After some web search I found a solution to check after deactivating individual Plugin's to check if its affecting!
    I was using, http://www.w3-edge.com/wordpress-plugins/w3-total-cache/ plugin, but after deactivating, my page started working, but the issue now is it goes to infinite loops.
    Code of Archive.php

    <?php
    /**
     * The template for displaying Archive pages.
     *
     * Used to display archive-type pages if nothing more specific matches a query.
     * For example, puts together date-based pages if no date.php file exists.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    
    get_header(); ?>
    <?php if ( function_exists('yoast_breadcrumb') ) {
    yoast_breadcrumb('<p id="breadcrumbs">','</p>');
    } ?>
    		<section id="primary">
    
    			<?php if ( have_posts() ) : ?>
    
    				<header class="page-header">
    					<h1 class="page-title">
    						<?php if ( is_day() ) : ?>
    							<?php printf( __( 'Daily Archives: %s', 'twentyeleven' ), '<span>' . get_the_date() . '</span>' ); ?>
    						<?php elseif ( is_month() ) : ?>
    							<?php printf( __( 'Monthly Archives: %s', 'twentyeleven' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentyeleven' ) ) . '</span>' ); ?>
    						<?php elseif ( is_year() ) : ?>
    							<?php printf( __( 'Yearly Archives: %s', 'twentyeleven' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentyeleven' ) ) . '</span>' ); ?>
    						<?php else : ?>
    							<?php _e( 'Blog Archives', 'twentyeleven' ); ?>
    						<?php endif; ?>
    					</h1>
    				</header>
    
    <?php twentyeleven_content_nav( 'nav-above' ); ?>
    
    				<?php /* Start the Loop */ ?>
    				<?php while ( have_posts() ) : the_excerpt();  ?>
    
    					<?php
    						/* Include the Post-Format-specific template for the content.
    						 * If you want to overload this in a child theme then include a file
    						 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    						 */
    get_template_part( 'content', get_post_format() );
    
    					?>
    
    				<?php endwhile; ?>
    
    				<?php twentyeleven_content_nav( 'nav-below' ); ?>
    
    			<?php else : ?>
    
    				<article id="post-0" class="post no-results not-found">
    					<header class="entry-header">
    						<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
    					</header><!-- .entry-header -->
    
    					<div class="entry-content">
    						<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
    						<?php get_search_form(); ?>
    					</div><!-- .entry-content -->
    				</article><!-- #post-0 -->
    
    			<?php endif; ?>
    
    			</div><!-- #content -->
    		</section><!-- #primary -->
    <?php get_footer(); ?>

    Content of Content.php

    <?php
    /**
     * The default template for displaying content
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    ?>
    
    	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> onClick="window.open('<?php the_permalink(); ?>','_self');">
    		<header class="entry-header">
    			<?php
    if (is_sticky()):
    ?>
    				<hgroup>
    					<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php
        printf(esc_attr__('Permalink to %s', 'twentyeleven'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    					<h3 class="entry-format"><?php _e('Featured', 'twentyeleven'); ?></h3>
    				</hgroup>
    			<?php
    else:
    ?>
    		  	<h3 class="entry-format">
    				<?php $category = get_the_category();
    					if  ($category[0]->cat_ID == 4 || $category[0]->cat_ID == 17 || $category[0]->cat_ID == 63) {
    						echo $category[1]->cat_name;
    					} else {
    						echo $category[0]->cat_name;
    					}
    				?>
    			</h3>
    			<h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php
        printf(esc_attr__('Permalink to %s', 'twentyeleven'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title();
    ?></a></h1>
    			<?php endif; ?>
    
    			<?php if ('post' == get_post_type()): ?>
    			<!-- <div class="entry-meta">
    				<?php twentyeleven_posted_on(); ?>
    			</div> .entry-meta -->
    			<?php endif; ?>
    
    			<?php if (comments_open() && !post_password_required()): ?>
    			<div class="comments-link">
    				<?php
        comments_popup_link('<span class="leave-reply">' . __('Reply', 'twentyeleven') . '</span>', _x('1', 'comments number', 'twentyeleven'), _x('%', 'comments number', 'twentyeleven')); ?>
    			</div>
    			<?php endif; ?>
    		</header><!-- .entry-header -->
    
    		<?php if (is_home()): // Only display Excerpts for Search  ?>
    		<div class="entry-summary">
    <?php
    //if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it.
    //      the_post_thumbnail();
    //  }
     if ( has_post_thumbnail()) {
    	$image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail');
    	//echo '<img src="http://cfci.org.in/wp-content/plugins/camera-slideshow/scripts/timthumb.php?src='. $image_url[0] .'"/>';
    echo '<img src="'.$image_url[0].'"/>';
     }
    ?>
    			 <?php // the_excerpt(); ?>
    <?php
     $permalink = get_permalink();
     $text      = $post->post_excerpt;
    //if (strlen($text) > 150) {
    //    $text = substr($text, 0, strpos($text, ' ', 150));
    //};
    //$text = $text . ' ...';
    $text .= '</br><a class="readMore" href="';
      $text .= $permalink;
      $text .= '">Continue Reading</a>';
      echo apply_filters('the_excerpt', $text);
    ?>
    		</div><!-- .entry-summary -->
    <?php
    elseif (is_archive()): // Only display Excerpts for Search
    ?>
    		<div class="entry-summary">
    <?php
        if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it.
            the_post_thumbnail();
        }
    ?>
    			<?php
        the_excerpt();
    ?>
    
    		</div><!-- .entry-summary -->
    		<?php
    else:
    ?>
    		<div class="entry-content">
    	  		<?php
        the_content(__('Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven'));
    ?>
    			<?php
        wp_link_pages(array(
            'before' => '<div class="page-link"><span>' . __('Pages:', 'twentyeleven') . '</span>',
            'after' => '</div>'
        ));
    ?>
    		</div><!-- .entry-content -->
    		<?php
    endif;
    ?>
    
    		<footer class="entry-meta">
    			<?php
    $show_sep = false;
    ?>
    			<?php
    if ('post' == get_post_type()): // Hide category and tag text for pages on Search
    ?>
    			<?php
        /* translators: used between list items, there is a space after the comma */
        $categories_list = get_the_category_list(__(', ', 'twentyeleven'));
        if ($categories_list):
    ?>
    			<span class="cat-links">
    				<?php
            printf(__('<span class="%1$s">Posted in</span> %2$s', 'twentyeleven'), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list);
            $show_sep = true;
    ?>
    			</span>
    			<?php
        endif; // End if categories
    ?>
    			<?php
        /* translators: used between list items, there is a space after the comma */
        $tags_list = get_the_tag_list('', __(', ', 'twentyeleven'));
        if ($tags_list):
            if ($show_sep):
    ?>
    			<span class="sep"> | </span>
    				<?php
            endif; // End if $show_sep
    ?>
    			<span class="tag-links">
    				<?php
            printf(__('<span class="%1$s">Tagged</span> %2$s', 'twentyeleven'), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list);
            $show_sep = true;
    ?>
    			</span>
    			<?php
        endif; // End if $tags_list
    ?>
    			<?php
    endif; // End if 'post' == get_post_type()
    ?>
    
    			<?php
    if (comments_open()):
    ?>
    			<?php
        if ($show_sep):
    ?>
    			<span class="sep"> | </span>
    			<?php
        endif; // End if $show_sep
    ?>
    			<span class="comments-link"><?php
        comments_popup_link('<span class="leave-reply">' . __('Leave a reply', 'twentyeleven') . '</span>', __('<b>1</b> Reply', 'twentyeleven'), __('<b>%</b> Replies', 'twentyeleven'));
    ?></span>
    			<?php
    endif; // End if comments_open()
    ?>
    
    //<?php
    edit_post_link(__('Edit', 'twentyeleven'), '<span class="edit-link">', '</span>');
    ?>
    		</footer><!-- #entry-meta -->
    	</article><!-- #post-<?php
    the_ID();
    ?> -->

    Do help me out :)

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    in archive.php, this line:

    <?php while ( have_posts() ) : the_excerpt();  ?>

    should be:

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

    if needed, put the excerpt code somewhere back into content.php

    the_post() is needed to advance the loop;
    http://codex.wordpress.org/Function_Reference/the_post

  5. Kelvin Castelino
    Member
    Posted 1 year ago #

    Yes it worked fine! Thank you so much!
    Will have to work on a logic in the content page! But why the_post should be creating an issue with infinite looping is what I didnt understand!

  6. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    why the_post should be creating an issue with infinite looping

    removing the_post() does create the issue;

    the_post() is needed to push the loop to the next post, so that at some point there are no more posts and the 'while' condition is no longer fullfilled which stops the loop.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic