Crear sección de artículos destacados en Wordpress

  • Autor Autor sebasxnco
  • Fecha de inicio Fecha de inicio
S

sebasxnco

Épsilon
hola forobeta estoy haciendo una sección de destacados para wordpress y me encontré un código de un tema ya echo pero tiene funciones y cosas creadas por el autor como las cambio para que sea un simple código que muestre los artículos destacados con el custom-field Image

PHP:
<!-- Highlights // -->
		<span class="heading2"><span>Highlights</span></span>
		<ul class="highlights">
		<?php $highlight1 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_1')."&showposts=1"); while($highlight1->have_posts()) : $highlight1->the_post();?>
			<li>
			<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
				<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
			<?php endif; ?>
				<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
				<span class="cat"><?php the_category(', '); ?></span>
			</li>
		<?php endwhile; ?>

		<?php $highlight2 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_2')."&showposts=1"); while($highlight2->have_posts()) : $highlight2->the_post();?>
			<li>
			<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
				<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
			<?php endif; ?>
				<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
				<span class="cat"><?php the_category(', '); ?></span>
			</li>
		<?php endwhile; ?>

		<?php $highlight3 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_3')."&showposts=1"); while($highlight3->have_posts()) : $highlight3->the_post();?>
			<li>
			<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
				<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
			<?php endif; ?>
				<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
				<span class="cat"><?php the_category(', '); ?></span>
			</li>
		<?php endwhile; ?>

		</ul>
		<div class="clear"></div>
		<!-- // Highlights -->
 
este código hace exactamente lo que quieres. en todo caso y para ser mas preciso, cambia thumbnail por Image, ya que el autor llama a la campo de la imagen del destacado, o sea su custom-field, 'thumbnail'.
 
Atrás
Arriba