[Resolved] Category pages

Home Forums Support [Resolved] Category pages

Home Forums Support Category pages

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #200152
    Wendy Peck

    Hi — I am having trouble with getting pages to display properly with Generate Press. I love this theme, and have used it over a dozen times, so I am pretty sure it is not the theme, but I still need help with the code. I am a designer who usually does OK reading and cutting and pasting php, but this one has me stumped. I have successfully used this in other templates.

    The template I have here displays intro text (the content of this page) plus the excerpt for any posts with the category that matches the title of the page. It’s working, but is also adding another entry above the comments. I am not sure where that is coming from, but it’s no doubt something from the loop I am just not getting.

    get_header(); ?>
    	<div id="primary" <?php generate_content_class();?>>
    		<main id="main" <?php generate_main_class(); ?>>
    			<?php do_action('generate_before_main_content'); ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php get_template_part( 'content', 'page' ); ?>
    <?php query_posts('category_name='.get_the_title().'&post_status=publish,future');?>
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    	<p><?php the_excerpt(); ?></p>
    	<?php endwhile; else: endif; ?>
    				// If comments are open or we have at least one comment, load up the comment template
    				if ( comments_open() || '0' != get_comments_number() ) : ?>
    					<div class="comments-area">
    						<?php comments_template(); ?>
    				<?php endif; ?>
    			<?php endwhile; // end of the loop. ?>
    		</main><!-- #main -->
    	</div><!-- #primary -->

    If anyone can spot the problem, I would be eternally thankful.

    And if you can give me a hint as to what I would need to change to do exactly the same thing with custom posts and custom categories for each post, that would get you my undying devotion (for quite a while). 🙂

    Lead Developer
    Lead Developer

    Hi there,

    Questions like this are perfect for http://wordpress.stackexchange.com/ as it’s a general WordPress question. Answers are much quicker there as it’s a huge community.

    The issue most likely has to do with your use of query_posts(). I prefer using WP_Query(): https://codex.wordpress.org/Class_Reference/WP_Query

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.