Forums

[resolved] Show a post list of current category (1 post)

  1. hbalagh
    Member
    Posted 2 years ago #

    I'm using the code below to show a list of post from the category I am in

    as seen here http://www.bpdfriends.com/section/blog/

    however for some reason its showing a post there /blog/ is a parent category with no post in it... but its still choosing to display a post from the http://www.bpdfriends.com/section/blog/bipolar-blog/

    both of the following work perfect (they are child categories)
    http://www.bpdfriends.com/section/blog/bipolar-blog/
    http://www.bpdfriends.com/section/blog/bpd-blog/

    any way of altering the code to now show the post

    <?php
    	global $post;
    	if(is_category() || is_single()){
    	foreach(get_the_category() as $category)
    	{
    	$current = $category->cat_ID;
    	$current_name = $category->cat_name;
    
    	//query_posts("cat=". $current);
    
    	$myposts = get_posts(array('category__in' => array($current)));
    
    	//$myposts = get_posts('numberposts=50&category='.$current); 
    
    	//query_posts(array('category__in' => array(11)));
    		}
    	}
    
    	foreach($myposts as $post) :
    	setup_postdata($post); 
    
    	?>
    	<li>
    	<a href="<?php the_permalink(); ?>">
    	<?php the_title(); ?></a>
    	</li>
    
    	<?php endforeach; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.