Importing latest post to home page from blog that is on sub-folder


My website is on WordPress CMS.

I want to know is it possible to show the latest post to the homepage from the blog which is running on subfolder.

i am Matt Robson.
yes, it is Possible please check the below code. You can put this code in your Home page.

/*Blog short code*/
function blog_list($atts)
    $args = array(
        'posts_per_page' => 5,
        'order' => 'DESC'
    $cpt_post = new WP_Query($args);
    $code_output .= '<div class="container"><div class="latest-blogs mt-3 mb-5">';

    if (is_front_page() || is_home()) {
        $code_output .= '<h4 class="text-capitalize section-title font-weight-bold section-border"><!-- Latest Blog News -->Featured Blog Articles</h4>';
    } else {
        $code_output .= '<h6 class="text-capitalize footer-title-text text-center"><!-- Latest Blog News -->Featured Blog Articles</h6><div class="section-heading-sep"></div>';
    $code_output .= '<div class="row m-0"><div class="owl-carousel owl-custom-slider owl-theme">';
    if ($cpt_post->have_posts()) :
        while ($cpt_post->have_posts()) :
            $code_output .= '<div class="item common-blog m-1">';
            $code_output .= get_the_post_thumbnail(get_the_ID(), 'custom-size-blog', array('class' => 'img-fluid mx-auto d-block'));
            $code_output .= '<div class="cards p-3"><p class="text-blog-date pb-2 mb-0">' . get_the_date() . '</p>';

            $code_output .= '<a class="decoration text-black" href=' . get_the_permalink() . '><p class="footer-title-text font-weight-bold pb-2 mb-0">' . esc_html(get_the_title()) . '</p></a>';
            $code_output .= '<p class="text-regular pb-2 mb-0">' . get_the_excerpt() . '</p>';
            $code_output .= '<a class="text-regular decoration text-read_more-link pb-2 mb-0" href="' . get_the_permalink() . '">Learn More <i class="fas fa-angle-right"></i></a>';
            $code_output .= '</div></div>';
    echo $code_output .= '</div><div class="col-lg-12 col-md-12 col-12 text-center mt-lg-4 mt-md-4 mt-4">
                        <a href="' . site_url() . '/blog/" class="decoration btn-viewmore text-center">View more</a>
    echo $code_output;
    //printf( '%s', $code_output );
    return $code_output;

heare is a short code for the function:
add_shortcode(‘xyz_blog_list’, ‘blog_list’);

Thank & Regards,
Matt Robson

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.