martes, 4 de diciembre de 2018

Wordpress - Traer elementos del post (Entradas)

diciembre 04, 2018 // by Alex // // No comments

BÁSICO

PHP

<?php query_posts('category_name=noticias&posts_per_page=2&order=ASC'); ?>

PHP

<?php
while(have_posts()):

TRAE EL POST
the_post();

TITULO:
the_title();

FECHA:
echo the_date();

IMAGEN:
$thumbID = get_post_thumbnail_id( $beneficios->ID );
$imgDestacada = wp_get_attachment_url( $thumbID );

endwhile;
?>

EJEMPLO CON PAGINACION Y SOBRE COLUMNAS

PHP


<?php

$args = array(
'category_id' => 15,
'category_name' => 'blog',
'posts_per_page' => 4,
'order' => 'ASC',
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)
);

query_posts($args);

?>

<div class="container">
<div class="row">

<?php
while(have_posts()):
the_post();?>
<div data-aos="flip-left"
data-aos-easing="ease-out-cubic"
data-aos-duration="2000" class="col-md-6">
<a class="item" href="<?php the_permalink(); ?>">
<div class="bl-text-blog">
<p><?php the_content(); ?></p>
</div>
</a>
</div>

<?php
endwhile;
?>


<div class="navegaciones">
<?php the_posts_pagination(); ?>
</div>
<?php wp_reset_query(); ?>
</div>

</div>

0 comentarios:

Publicar un comentario