listing categories and posts of current category: is_single problem
-
Hi all,
so i have the following code:
<?php // get all the categories from the database $cats = get_categories(); // loop through the categries foreach ($cats as $cat) { // setup the cateogory ID $cat_id= $cat->term_id; // Make a header for the cateogry echo '<h2><a href="./?cat='.$cat->term_id.'">'.$cat->name.'</h2>'; // create a custom wordpress query query_posts("cat=$cat_id"); ?> <?php if (in_category($cat_id)) { ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php // create our link now that the post is setup ?> <a href="<?php the_permalink();?>"><?php the_title(); ?></a><br> <?php endwhile; ?> <?php endif; // done our wordpress loop. Will start again for each category ?> <?php } else { ?> <?php } ?> <?php } // done the foreach statement ?>
this code makes my category post show when i’m on that current category page. I wanted to add the following thing in the
have posts
loop (it should make Yes appear under EACH the post title on single post 84, and no everywhere else… :<?php if (is_single('84')) { ?> Yes <?php } else { ?> no <?php } ?>
But: is_single seems not to be working inside the loop. when i put it outside the loop it works in combination with a wp_reset_query prior to the code, but i really need it inside the loop.
I dont know if this is proper code, but i’m learning as im doing it actually, so be easy on me ??
thanks!
edit:
a screenshot perhaps!
SCREENSHOT
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘listing categories and posts of current category: is_single problem’ is closed to new replies.