Noticias

<?php
/**
 * Template Name: Archivo de Noticias
 */

get_header(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

        <?php
        $args = array(
            'category_name' => 'noticias', // Nombre de la categoría 'noticias'
            'posts_per_page' => -1, // Mostrar todas las entradas
        );

        $query = new WP_Query($args);

        if ($query->have_posts()) :
            while ($query->have_posts()) : $query->the_post();
        ?>

                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <header class="entry-header">
                        <?php the_title('<h2 class="entry-title">', '</h2>'); ?>
                    </header><!-- .entry-header -->

                    <div class="entry-content">
                        <?php
                        if (has_post_thumbnail()) {
                            the_post_thumbnail('thumbnail'); // Muestra la miniatura de la entrada
                        }
                        the_excerpt(); // Muestra el extracto de la entrada
                        ?>
                    </div><!-- .entry-content -->
                </article><!-- #post-<?php the_ID(); ?> -->

        <?php
            endwhile;
            wp_reset_postdata();
        else :
            echo 'No se encontraron entradas.';
        endif;
        ?>

    </main><!-- #main -->
</div><!-- #primary -->

<?php
get_footer();

Crea una web o blog en WordPress.com

Subir ↑