Show Latest Blog Posts on the Homepage

Laraship QuestionsCategory: TechnicalShow Latest Blog Posts on the Homepage
Arif Hidyawan asked 6 years ago

Do you have or know how I could show latest blog posts on the homepage?

1 Answers
laraship Staff answered 6 years ago

Depends on your theme, you need to edit the home page template, some themes we have like the neptun theme has latest blogs in home page , you can use a function called getLatestPosts({number of posts}) for example

        <!-- ******Latest blog Section****** -->
        <section id="latest-blog" class="latest-blog section">
            <div class="container">
                <h2 class="title text-center"> @lang('corals-neptune::labels.template.latest_posts')</h2>
                <div class="row">
                    @foreach(\CMS::getLatestPosts(4) as $post)
                        <div class="item col-md-6 col-12">
                            <div class="item-inner">
                                <figure class="figure">
                                    <a href="{{ url($post->slug) }}">
                                        <img class="img-fluid"
                                             src="{{ $post->featured_image }}"
                                             alt="{{ $post->title }}"/>
                                <div class="content-wrapper text-center">
                                    <h3 class="sub-title"><a href="{{ url($post->slug) }}">{{ $post->title }}</a></h3>
                                    <div class="desc">
                                            {{ str_limit(strip_tags($post->rendered )) }}
                                </div><!--//content-wrapper text-center-->