Forums

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

  1. fotofio
    Member
    Posted 3 years 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 3 years 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 3 years ago #

    change $title to $post->post_title

  4. fotofio
    Member
    Posted 3 years 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 3 years ago #

    I would look into changing

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

Topic Closed

This topic has been closed to new replies.

About this Topic