Side bar Random post PHP or condition
-
Hi guys,
My website layout is very complex with unique category templates and side bars. I am trying to have the same sidebar for single posts and chose categories but it is not working.<?php if (is_single()) { <– works
<?php if (is_single() || is_category()) { <- works but i dont want it in all categories
<?php if (is_single(‘8’)) { <– doesn’t work, i made sure the category is 8 and i tried also the category name with no luck.Thanks
<div class="sidebarbox"> <!-- related posts sidebar --> <?php if (is_single() || is_category('8')) { if (get_the_category()) { ?> <?php foreach((get_the_category()) as $category) { echo '<h2>Related Posts: '.$category->cat_name.'</h2>'."\r\n<ul>"; query_posts('cat='.$category->cat_ID.'&limit=10'); while (have_posts()) { the_post(); ?> <li><a href="<?php the_permalink() ?>" title="permalink to <?php the_title() ?>"><?php the_title() ?></a></li> <?php } echo "</ul>\r\n"; } } }?> </div>
The topic ‘Side bar Random post PHP or condition’ is closed to new replies.