Forums

how to get posts from specific category but .... pls help me (4 posts)

  1. rober7
    Member
    Posted 9 months ago #

    how to get featured posts from specific category.
    ex: only the posts from "web" and "featured" category. ... i want to add a "Latest featured posts from CATEGORY-WEB "

  2. alchymyth
    The Sweeper
    Posted 9 months ago #

  3. rober7
    Member
    Posted 9 months ago #

    i use this code to display latest from a specific cat

    <ul>
    		<?php $recent = new WP_Query("cat=34&showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
    		<li><a href="<?php the_permalink(); ?>"><img src="<?php echo bloginfo('template_url'); ?>/lib/scripts/thumb.php?src=/<?php
    		$values = get_post_custom_values("thesis_thumb");if (empty($values)) {echo '/wp-content/themes/thesis_18/custom/noimg.png';}; echo $values[0]; ?>" alt="<?php the_title(); ?>" class="footer-thumb" width="35" height="35" /></a>
    		<div class="recent-post-content-featured">
    		<p><a title="Post: <?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
    		</div>
    		</li>
    		<?php endwhile; ?>
    		</ul>

    how can i do to show latest from a specific category but to be in the "featured" cat too ?

  4. alchymyth
    The Sweeper
    Posted 9 months ago #

    try to replace this line:
    <?php $recent = new WP_Query("cat=34&showposts=5");
    with:

    <?php $featured_id = get_cat_ID('featured');
    $recent = new WP_Query( array('category__and => array(34, $featured_id), posts_per_page' => 5) );

Reply

You must log in to post.

About this Topic