Skip to main content
added 40 characters in body
Source Link

Get First Five Posts With Specific Category

<?php
        // the query
        $the_query = new WP_Query(array(
            'category_name' => 'post_category_name',
            'post_status' => 'publish',
            'posts_per_page' => 5,
        ));
        ?>

        <?php if ($the_query->have_posts()) : ?>
            <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
                <?php the_category(); ?>
                <?php the_title(); ?>
                <?php the_excerpt(); ?>
                <?php the_post_thumbnail(); ?>
                <?php the_content(); ?>

            <?php endwhile; ?>
            <?php wp_reset_postdata(); ?>

        <?php else : ?>
            <p><?php __('No News'); ?></p>
        <?php endif; ?>

Get First Five Posts With Specific Category

<?php
        // the query
        $the_query = new WP_Query(array(
            'category_name' => 'post_category_name',
            'post_status' => 'publish',
            'posts_per_page' => 5,
        ));
        ?>

        <?php if ($the_query->have_posts()) : ?>
            <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>

                <?php the_title(); ?>
                <?php the_excerpt(); ?>
                <?php the_post_thumbnail(); ?>
                <?php the_content(); ?>

            <?php endwhile; ?>
            <?php wp_reset_postdata(); ?>

        <?php else : ?>
            <p><?php __('No News'); ?></p>
        <?php endif; ?>

Get First Five Posts With Specific Category

<?php
        // the query
        $the_query = new WP_Query(array(
            'category_name' => 'post_category_name',
            'post_status' => 'publish',
            'posts_per_page' => 5,
        ));
        ?>

        <?php if ($the_query->have_posts()) : ?>
            <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
                <?php the_category(); ?>
                <?php the_title(); ?>
                <?php the_excerpt(); ?>
                <?php the_post_thumbnail(); ?>
                <?php the_content(); ?>

            <?php endwhile; ?>
            <?php wp_reset_postdata(); ?>

        <?php else : ?>
            <p><?php __('No News'); ?></p>
        <?php endif; ?>
Source Link

Get First Five Posts With Specific Category

<?php
        // the query
        $the_query = new WP_Query(array(
            'category_name' => 'post_category_name',
            'post_status' => 'publish',
            'posts_per_page' => 5,
        ));
        ?>

        <?php if ($the_query->have_posts()) : ?>
            <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>

                <?php the_title(); ?>
                <?php the_excerpt(); ?>
                <?php the_post_thumbnail(); ?>
                <?php the_content(); ?>

            <?php endwhile; ?>
            <?php wp_reset_postdata(); ?>

        <?php else : ?>
            <p><?php __('No News'); ?></p>
        <?php endif; ?>