WordPress.org

Ready to get started?Download WordPress

Forums

Don't display 5 posts with cat featured (1 post)

  1. yagrasdemonde
    Member
    Posted 5 years ago #

    Hi everybody.
    I have a trouble in my query.
    I use PremiumNews theme and I have a featured page within I display the 5 last posts of featured category.

    In my layout page, default.php I want to display ALL posts of all categories except the 5 posts displayed in my div featured at the top of my page.

    I don't to put in place the loop with $do_not_duplicate.

    Help me please...

    featured.php page :

    <?php 
    
    	$featuredcat = get_option('woo_featured_category'); // ID of the Featured Category
    	$the_query = new WP_Query('category_name=' . $featuredcat . '&showposts=5&orderby=post_date&order=desc');
    
    	$counter = 0;
    
    	while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
    
    ?>
    
    	<?php $counter++; ?>
    
    	<div class="featured" id="post-<?php the_ID(); ?>"> 
    
    		<?php if ( get_post_meta($post->ID, 'image', true) ) { ?> <!-- DISPLAYS THE IMAGE URL SPECIFIED IN THE CUSTOM FIELD -->
    
    			<div class="featured-img" style="background:url(<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&h=200&w=350&zc=1&q=95) top left no-repeat;">
    				<?php if ($counter == 1) { ?><div id="ribbon"><img src="<?php bloginfo('stylesheet_directory'); ?>/styles/<?php echo "$style_path"; ?>/ribbon.png" alt="A la une !!!"  /></div><?php } ?> <!-- SHOW "FEATURED" RIBBON FOR FIRST POST ONLY -->
    			</div>				
    
    		<?php } else { ?> <!-- DISPLAY THE DEFAULT IMAGE, IF CUSTOM FIELD HAS NOT BEEN COMPLETED -->
    
    			<div class="featured-img" style="background:url(<?php bloginfo('template_directory'); ?>/images/no-img-large.jpg) top left no-repeat;">
    				<?php if ($counter == 1) { ?><div id="ribbon"><img src="<?php bloginfo('stylesheet_directory'); ?>/styles/<?php echo "$style_path"; ?>/ribbon.png" alt="A la une !!!"  /></div><?php } ?> <!-- SHOW "FEATURED" RIBBON FOR FIRST POST ONLY -->
    			</div>
    
    		<?php } ?> 
    
    		<h2><?php the_category(', ') ?></h2>
    		<h3><a title="Lien permanent pour <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    		<p><?php echo strip_tags(get_the_excerpt(), '<a><strong>'); ?></p>
    		<p style="margin-bottom:0px !important;"><span class="continue"><a title="Lien permament pour <?php the_title(); ?>" href="<?php the_permalink() ?>">Continuer...</a></span></p>
    
    	</div><!--/featured-->
    
    <?php endwhile; ?>
    
    <div id="featured-th">
    
    	<ul class="idTabs">
    
    		<?php
    			$the_query = new WP_Query('category_name=' . $featuredcat . '&showposts=5&orderby=post_date&order=desc');
    
    			$counter = 0;
    
    			while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
    
    		?>
    
    		<?php $counter++; ?>
    
    		<?php if ( get_post_meta($post->ID, 'image', true) ) { ?> <!-- DISPLAYS THE IMAGE URL SPECIFIED IN THE CUSTOM FIELD -->
    
    			<li <?php if ($counter == 5) { ?>class="last"<?php } ?>><a href="#post-<?php the_ID(); ?>"><img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&h=57&w=100&zc=1&q=95" alt=""/></a></li>			
    
    		<?php } else { ?> <!-- DISPLAY THE DEFAULT IMAGE, IF CUSTOM FIELD HAS NOT BEEN COMPLETED -->
    
    			<li <?php if ($counter == 5) { ?>class="last"<?php } ?>><a href="#post-<?php the_ID(); ?>"><img src="<?php bloginfo('template_directory'); ?>/images/no-img-thumb.jpg" alt=""/></a></li>
    
    		<?php } ?> 		
    
    		<?php endwhile; ?>
    
    	</ul>
    
    </div><!--/featured-th-->

    default.php page :

    <div class="box">
    
    	<?php
    		include(TEMPLATEPATH . '/includes/version.php');
    
    		$the_query = new WP_Query('cat=-'. $ex_vid . '&showposts=' . $showposts . '&orderby=post_date&order=desc');
    
    		$counter = 0; $counter2 = 0;
    
    		while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
    
    	?>
    
    		<?php $counter++; $counter2++; ?>
    
    		<div class="post <?php if ($counter == 1) { echo 'fl'; } else { echo 'fr'; $counter = 0; } ?>">
    
    			<?php if ( get_post_meta($post->ID, 'image', true) ) { ?> <!-- DISPLAYS THE IMAGE URL SPECIFIED IN THE CUSTOM FIELD -->
    
    				<img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&h=57&w=100&zc=1&q=95" alt="" class="th" />			
    
    			<?php } else { ?> <!-- DISPLAY THE DEFAULT IMAGE, IF CUSTOM FIELD HAS NOT BEEN COMPLETED -->
    
    				<img src="<?php bloginfo('template_directory'); ?>/images/no-img-thumb.jpg" alt="" class="th" />
    
    			<?php } ?> 
    
    			<h2><?php the_category(', ') ?></h2>
    			<h3><a title="Lien permanent pour <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    			<p class="posted">Posté le <?php the_time('d F Y'); ?></p>
    			<p><?php echo strip_tags(get_the_excerpt(), '<a><strong>'); ?> <span class="continue"><a title="Lien permanent pour <?php the_title(); ?>" href="<?php the_permalink() ?>">Continuer...</a></span></p>
    			<p class="comments"><?php comments_popup_link('Aucun commentaire', '1 commentaire', '% commentaires'); ?></p>
    
    		</div><!--/post-->
    
    		<?php if ( !($counter2 == $showposts) && ($counter == 0) ) { echo '<div class="hl-full"></div>'; ?> <div style="clear:both;"></div> <?php } ?>
    
    	<?php endwhile;	?>
    
    	<div class="fix" style="height:20px"></div>
    
    	<p class="ar hl3"><a href="<?php echo bloginfo('wpurl').'/?page_id='.$GLOBALS['archives_id']; ?>" class="more">VOIR PLUS D'ARTICLES DANS LES ARCHIVES</a></p>
    
    </div><!--/box-->

Topic Closed

This topic has been closed to new replies.

About this Topic