So I have a site using the sidebar to display a all the posts in a specific category. I noticed that this only worked on certain categories. After a little investigation, I discovered that by shortening the length of nonworking categories, I could get them to work.
Perhaps I'm going about this the wrong way, but here is my code:
<?php //get the current category and put into $category var $category = get_the_category(); echo "<h2 class='headline'>".$category->cat_name."</h2>"; // some posts are in multiple categories, i'll just grab the first one $cat = $category->cat_name; ?> <?php $recent = new WP_Query(); ?> // for testing what the 'get_the_category()' output was <?php echo "cat: ".$cat; ?> // this was working for some categories but not others <?php $recent->query('category_name='.$cat.'&showposts=-1'); ?> <?php while($recent->have_posts()) : $recent->the_post(); ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br /> <?php endwhile; ?>
So basically here is what I was able to determine:
category name: condos & beach houses ---- too long
category name: condos and beach houses -- too long
category name: condos beach houses ------ works ok
anyone else ever come across this?