• What I am trying to do:

    I want the archives (or category) template to have a featured posts area at the top that only show posts with the tag ‘featured’ followed by the standard list of posts for that category.

    The best code I’ve been able to come up with is below.

    The problem with this code: is it’s not grabbing the_excerpt info unless their is actually content in the excerpt box. Generally, if no specific excerpt info has been added to the post, the_excerpt will grab the info from the post content.

    <?php $cat = get_the_category(); $cat = $cat[0]; ?>
    
    <?php
    $myposts = get_posts('numberposts=4&tag=featured&category='.$cat->cat_ID);
    foreach($myposts as $post) :
    ?>
    
    <div <?php post_class('featured') ?> id="post-<?php the_ID(); ?>">
    
    <?php the_title(); ?>
    
    <?php the_excerpt(); ?>
    
    </div>
    
    <?php endforeach; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Querry_post / get_post and archive.php, can't get it to work’ is closed to new replies.