Lopezito
Zeta
Diseñador
Verificación en dos pasos activada
Verificado por Whatsapp
<?php
function ultimosactualizados(){
$cpost = 10; // Cantidad de posts a mostrar
$cletras = 30; // Cantidad de letras a mostrar en el extracto del post
?>
<!-- Ultimos actualizados por Lopezito -->
<section class="aposts">
<h3>Últimos actualizados.</h3>
<?php
query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC'));
while ( have_posts() ) : the_post();
?>
<article class="apost">
<a href="<?php the_permalink(); ?>" title="Enlace permanente hacia <?php the_title_attribute(); ?>"><h5><?php the_title(); ?></h5></a>
<section class="acont">
<a href="<?php the_permalink(); ?>" title="Enlace permanente hacia <?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
<?php echo substr(get_the_excerpt(),0,$cletras); ?>...
</main>
</article>
<?php
endwhile;
wp_reset_query();
?>
</section>
<!-- / Ultimos actualizados por Lopezito -->
<?php
}
?>
.aposts{padding:5px;margin:5px 0}
.aposts h3{font-weight:100;padding:10px;color:#FFF;font-size:19px;text-shadow:1px 1px rgba(88, 88, 88, 0.33);display:inline-block;background:#74B2CF!important;letter-spacing:1px}
.apost{background:#fff!important;border-top:1px solid #eee!important}
.apost:nth-child(2n+2){background:#F4FBFF!important}
.apost a h5{text-decoration:none;font-size:15px;font-weight:100;text-shadow:1px 1px #fff;color:#444;margin-bottom:5px;padding:5px}
.acont{margin:5px;overflow:hidden;color:#444;font-style:italic}
.acont a img{float:left;width:48px!important;height:48px!important;border:none!important;margin:5px 15px;box-shadow:0 0 8px #FFF}
<?php ultimosactualizados(); ?>
¿Y para mostrar los últimos artículos actualizados por Categoría/Tags?¿Es posible a partir de este código?
query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC'));
<?php
// Si queres agregarlo a category.php:
$cat_ID = get_query_var('cat');
query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC', 'cat' => $cat_ID));
// Si queres agregarlo en tag.php
$tag_ID = get_query_var('tag');
query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC', 'tag_id' => $tag_ID));
// Si no, podes agregar manualmente los datos
$cat_ID = array(1,2,3); // ID's de las categorías
query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC', 'cat' => $cat_ID));
$tag_ID = array(1,2,3); // ID's de las tags
query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC', 'tag_id' => $tag_ID));
?>
Sí en la línea:
PHP:query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC'));
PHP:<?php // Si queres agregarlo a category.php: $cat_ID = get_query_var('cat'); query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC', 'cat' => $cat_ID)); // Si queres agregarlo en tag.php $tag_ID = get_query_var('tag'); query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC', 'tag_id' => $tag_ID)); // Si no, podes agregar manualmente los datos $cat_ID = array(1,2,3); // ID's de las categorías query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC', 'cat' => $cat_ID)); $tag_ID = array(1,2,3); // ID's de las tags query_posts(array('posts_per_page' => $cpost, 'orderby' => 'modified', 'order' => 'DESC', 'tag_id' => $tag_ID)); ?>
oye capo, muchas gracias por compartir! mira tengo una duda hay forma de que en la home pueda mostrar los posts normalmente, pero si un post antiguo se actualiza, inemdiatamente pase al home de la web de nuevo, sin necesidad de modificar la fecha?
te agradeceria cualquier respuesta. saludos y gracias por compartir
oye capo, muchas gracias por compartir! mira tengo una duda hay forma de que en la home pueda mostrar los posts normalmente, pero si un post antiguo se actualiza, inemdiatamente pase al home de la web de nuevo, sin necesidad de modificar la fecha?
te agradeceria cualquier respuesta. saludos y gracias por compartir
query_posts(array('posts_per_page' => $cpost, 'orderby' => '[B][COLOR="#008000"]modified[/COLOR][/B]', 'order' => 'DESC'));
while ( have_posts() ) : the_post();
query_posts(array('posts_per_page' => $cpost, 'orderby' => '[B][COLOR="#008000"]date[/COLOR][/B]', 'order' => 'DESC'));
while ( have_posts() ) : the_post();
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?