Pete468
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Pagination not working with custom loopThanks for pointing me in the right direction.
I’ve incorporated next_posts_link and previous_posts_link as per the example and it works as expected. Thanks!Forum: Fixing WordPress
In reply to: Need help with my archive page loopThanks to both of you – that’s so kind!
I think I understand how it’s supposed to work now – and the example code works exactly as I wanted it to – VERY grateful!!Forum: Fixing WordPress
In reply to: Need help with my archive page loopI thought that the current category was passed to the page by the previous page (i.e. in the URL) – and that a generic loop could display posts based on the current category (without a specific category being explicit in the code). I guess what you’re saying is that query_posts isn’t the code I should be using for my generic category template?
Forum: Fixing WordPress
In reply to: Need help with my archive page loopHi – I really appreciated the help last time – Thanks!
I’m still having trouble with my category page loop. What I’m trying to do here is; display the category title, display the category description (if it exists), then display the full content of the latest post in that category, then display excerpts for the next x number of posts in that category, then display a “Next” link for the next page.
I think I’ve misunderstood something about how the loop works, because my code sucessfully displays the category title and description, but then lists posts from ALL categories instead of the current category.Any help will be greatly appreciated! Here’s my code:
<?php // Check if there are any posts to display if ( have_posts() ) : ?> <h1 class="archive-title"><?php single_cat_title( '', true ); ?></h1> <?php if ( category_description() ) : ?> <h5 class="slug-line"><?php echo category_description(); ?></h5> <?php endif; ?> <hr> <!--COLUMN 1--> <div id="column1"> <h2 class="section-title">Latest Story</h2> <?php query_posts('showposts=1&post_type=post'); ?> <?php // The Loop while ( have_posts() ) : the_post();?> <div class="item"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <small><?php the_time('F jS, Y') ?></small> <div class="entry"> <?php the_content(); ?> <p class="postmetadata"><?php _e( 'Posted in' ); ?> <em><?php the_category( ', ' ); ?> on <?php the_time('F jS, Y') ?></em></p> </div> <div class="comments-template"> <?php comments_template();?> </div> </div> <?php endwhile;?> <?php else : ?> <p>Sorry - no posts found</p> <?php endif; ?> <?php rewind_posts(); ?> </div><!--column-main--> <div id="column2"> <h2 class="section-title">More Stories</h2> <?php query_posts('showposts=10&offset=1&post_type=post'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="item article-preview"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3> <p class="date-stamp"><?php the_time('F jS, Y') ?></small></p> <?php if ( has_post_thumbnail()) : ?> <?php the_post_thumbnail('thumbnail', array('class' => 'articlethumb')); ?> <?php endif; ?> <div class="entry"> <?php the_excerpt(); ?> <p class="postmetadata"><?php _e( 'Posted in' ); ?> <em><?php the_category( ', ' ); ?> on <?php the_time('F jS, Y') ?></em></p> </div> <div class="comments-template"> <?php comments_template();?> </div> </div> <?php endwhile;?> <div class="navigation"> <?php posts_nav_link();?> </div> <?php else : ?> <p>Sorry - no posts found</p> <?php endif; ?>
Forum: Fixing WordPress
In reply to: Need help with my archive page loopOh my word! Really? It works.
I feel daft – Thanks a million for your help!Forum: Fixing WordPress
In reply to: Need help with my archive page loop<?php// Check if there are any posts to display if ( have_posts() ) : ?> <h1 class="archive-title"><?php single_cat_title( '', true ); ?></h1> <?php if ( category_description() ) : ?> <h5 class="slug-line"><?php echo category_description(); ?></h5> <?php endif; ?> <hr> <!--COLUMN 1--> <div id="column-single"> <?php // The Loop while ( have_posts() ) : the_post();?> <div class="item"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <small><?php the_time('F jS, Y') ?></small> <div class="entry"> <?php the_content(); ?> <p class="postmetadata"><?php _e( 'Posted in' ); ?> <em><?php the_category( ', ' ); ?> on <?php the_time('F jS, Y') ?></em></p> </div> <div class="comments-template"> <?php comments_template();?> </div> </div> <?php endwhile;?> <?php else : ?> <p>Sorry - no posts found</p> <?php endif; ?>
Forum: Fixing WordPress
In reply to: Need help with my archive page loopno – but there are two in this bit
Forum: Fixing WordPress
In reply to: Need help with my archive page loopThanks for the suggestion – but that creates an error: “Parse error: syntax error, unexpected ‘else’ (T_ELSE) in archive.php on line 53”
..which is the else at the end of the loop.