i brand new php , wordpress.
i use post categories simple directory , users see every post category when click on one, opposed paginating results.
in archive.php comes theme had tried this:
/* current category , increase number of posts shown */ <?php $category = $wp_query->get_queried_object()->slug; query_posts('category_name=$category&showposts=100'); ?> <div id="content"> <?php if ( have_posts() ) : ?> <?php /* loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php else : ?> <?php get_template_part( 'content', 'none' ); ?> <?php endif; ?> </div><!-- /content --> however, doesn't work. clicking on category shows no posts found.
i'm sure there better , simpler way go doing this.
a secondary question be, way apply logic subset of categories have? suppose make array of categories , query that, seems clumsy.
many thanks.
not sure if it'll solve problem, got bug in code:
<?php query_posts('category_name=$category&showposts=100'); a variable name in single quotes doesn't anything. variable expansion happens in double quote strings (see here well):
<?php query_posts("category_name=$category&showposts=100"); better yet skip variable expansion , proper concatenation:
<?php query_posts('category_name=' . $category . '&showposts=100');
Comments
Post a Comment