Skip to content

Instantly share code, notes, and snippets.

@webprogramacion
Last active January 9, 2017 09:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webprogramacion/460dba0837571129da7317a9b050374d to your computer and use it in GitHub Desktop.
Save webprogramacion/460dba0837571129da7317a9b050374d to your computer and use it in GitHub Desktop.
<?php
$args=array('post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => '3',
'orderby' => 'date',
'order' => 'DESC'
);
$posts = null;
$posts = new WP_Query($args);
if( $posts->have_posts() )
{
echo "<div class='ultimos_productos'>";
echo "<ul>";
while ($posts->have_posts())
{
echo "<li>";
$posts->the_post();
$titulo = get_the_title();
$resumen = get_the_excerpt();
$fecha = get_the_date();
$enlace = get_permalink();
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'medium', true);
$url_imagen=$thumb_url[0];
echo "<a href='$enlace'><h3>$titulo</h3></a>";
echo "<div class='imagenyresumen'>";
echo "<img class='imagen_producto' src='$url_imagen' /><br />";
echo "<p class='resumen_producto'>$resumen</p>";
echo "</div>";
echo "<p class='masinfo_producto'>";
echo "<a href='$enlace'>Ver más</a>";
echo "</p>";
echo "</li>";
}
echo "</ul>";
echo "</div>";
}
wp_reset_query();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment