Cómo evitar que los mismos artículos aparezcan en múltiples bloques

Emis Seguir

Dseda
Redactor
Verificación en dos pasos desactivada
Desde
10 Ago 2010
Mensajes
1.034
Buenas nuevamente quiero su ayuda.

En este sitio podrán observar donde dice "GAMING REVIEWS", "CINEMA REVIEWS", y "ANNOUNCEMENTS", cada articulo que contiene son los mismos, y lo que quiero hacer es que no salgan los mismos articulos en los 3 bloques.

Los articulos que salen en esos bloques son de la categoria "ANNOUNCEMENTS" yo en la configuracion del home.php configure para que cada uno salga con su categoria que deberia ser, les dejo parte del home.php para que vean.

PHP:
<div class="featured">
			<h3>GAMING REVIEWS</h3>
			
				<!--This is where the thumbnails are found for the homepage bottom section - note the custom field name for this image is "thumbnail". Recommended image size is 70x70, as the stylesheet is written for this size.-->
			
				<?php $recent = new WP_Query("/category/gaming-reviews&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
				<?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
				    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>
				<?php else: ?>
				   	<a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>
				<?php endif; ?>				
				<b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
				<?php the_content_limit(80, ""); ?>
				
				<div style="border-bottom:1px dotted #94B1DF; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
				
				<?php endwhile; ?>

				<!--This is where you can specify the archive link for each section. Replace the # with the appropriate URL-->
				
				<b><a href="http://www.madmotions.com/category/gaming-reviews" rel="bookmark">Read more Gaming Reviews</a></b>
				
			</div>			
				
		</div>
		
		<div id="homepageright">
		
			<!--This section is currently pulling category ID #1, and can be switched by changing the cat=1 to show whatever category ID you would like in this area.-->
		
			<div class="featured">
			<h3>CINEMA REVIEWS</h3>
			
				<!--This is where the thumbnails are found for the homepage bottom section - note the custom field name for this image is "thumbnail". Recommended image size is 70x70, as the stylesheet is written for this size.-->
			
				<?php $recent = new WP_Query("/category/cinema-reviews&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
				<?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
				    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>
				<?php else: ?>
				   	<a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>
				<?php endif; ?>				
				<b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>				
				<?php the_content_limit(80, ""); ?>
								
				<div style="border-bottom:1px dotted #94B1DF; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
				
				<?php endwhile; ?>
				
				<!--This is where you can specify the archive link for each section. Replace the # with the appropriate URL-->
				
				<b><a href="http://www.madmotions.com/category/cinema-reviews" rel="bookmark">Read more Cinema Reviews</a></b>
				
			</div>		
			
		</div>
		
		<div id="homepagebottom">
		
			<div class="hpbottom">
			
				<h3>ANNOUNCEMENTS</h3>
	
				<!--This is where the thumbnails are found for the homepage bottom section - note the custom field name for this image is "hpbottom". Recommended image size is 70x70, as the stylesheet is written for this size.-->
				
				<?php $recent = new WP_Query("/category/announcements&showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
				<?php if( get_post_meta($post->ID, "hpbottom", true) ): ?>
				    <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "hpbottom", true); ?>" alt="<?php the_title(); ?>" /></a>
				<?php else: ?>
				   	<a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>
				<?php endif; ?>				
				<b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
				<?php the_content_limit(350, "[Read more of this review]"); ?>
					
				<div style="border-bottom:1px dotted #2255AA; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
					
				<?php endwhile; ?>
	
				<!--This is where you can specify the archive link for each section. Replace the # with the appropriate URL-->
					
				<b><a href="http://www.madmotions.com/category/announcements" rel="bookmark">Read more from our Announcements</a></b>
			
			</div>
		
		</div>
		
	</div>


Veran donde dice
PHP:
<?php $recent = new WP_Query("/category/cinema-reviews&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
tiene colocado "/category/cinema-reviews&showposts=1" tendria que salir un post sobre la categoria "CINEMA REVIEWS" y no sale de esa categoria, el showpost=1 es obviamente para que se vea un solo post alli.

Saludos
 

Fabián Rodríguez

Lambda
Programador
Verificación en dos pasos desactivada
Desde
24 Mar 2008
Mensajes
2.850
Pero lo estás haciendo mal creo, porque estás colocando la ruta de la categoría, es decir, un string no reconocido como parámetro. Según las referencias de Wordpress sobre esta clase debes usar el parámetro "cat=id", osea, debería ir así:


PHP:
<?php $recent = new WP_Query("cat=5&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>

Creo que así si serviría...
 

juanma007

Delta
Verificación en dos pasos desactivada
Desde
24 Jun 2009
Mensajes
657
Prueba de esta manera:

$recent = new WP_Query( 'category_name=gaming-reviews&showposts=1' );
$recent = new WP_Query( 'category_name=cinema-reviews&showposts=1' );
$recent = new WP_Query( 'category_name=announcements&showposts=5' );
 

¡Regístrate y comienza a ganar!

Beneficios

  • Gana dinero por participar
  • Gana dinero por recomendarnos
  • Descubre ofertas de empleo diariamente
  • Negocios seguros
  • ¡Información premium y más!

Acceder

¿Ya tienes una cuenta? Accede aquí


Arriba