Forums

[resolved] Specific category posts not working in sidebar (5 posts)

  1. fotofio
    Member
    Posted 9 months ago #

    I am having dificulty on one project with the following code. The end result is the proper excerpt and read more links but the title for each of the two posts comes from yet another post in another category.

    Who can figure this one out?

    <div class="sidebar_box2" id="articlesTab">	<div class="mores"><p><a href="<?php next_post_link('%link', '', TRUE); ?>">More &raquo;</a></p></div>	
    
    <ul>
    <?php query_posts('category_name=fp&showposts=2'); //$do_not_duplicate = $post->ID;
    			 if (have_posts()) : while (have_posts()) : the_post();
    			 //if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts);
    			 ?>
    
    	<li>
    		<a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>"><?php echo $title ?></a>
    
    		<p class="text"><?php the_excerpt(); ?></p>
    		</li>
    
     <?php endwhile; endif; ?>
    
    </div>
  2. fotofio
    Member
    Posted 9 months ago #

    <div class="sidebar_box2" id="articlesTab">	<div class="mores"><p><a href="<?php next_post_link('%link', '', TRUE); ?>">More &raquo;</a></p></div>	
    
    <ul>
    <?php query_posts('category_name=fp&showposts=2'); //$do_not_duplicate = $post->ID;
    			 if (have_posts()) : while (have_posts()) : the_post();
    			 //if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts);
    			 ?>
    
    	<li>
    		<a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>"><?php echo $title ?></a>
    
    		<p class="text"><?php the_excerpt(); ?></p>
    		</li>
    
     <?php endwhile; endif; ?>
    
    </div>
  3. myinstinctwaswrong
    Member
    Posted 9 months ago #

    change $title to $post->post_title

  4. fotofio
    Member
    Posted 9 months ago #

    Thanks buddy, that got it done. The permakink is a little funky, seems to point to a revision? Any guidance there?

  5. myinstinctwaswrong
    Member
    Posted 9 months ago #

    I would look into changing

    get_permalink($postid) to get_permalink($post->ID)

Reply

You must log in to post.

About this Topic