Show Latest Blog Posts on the Homepage

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

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

1 Answers
laraship Staff answered 5 years ago

Hello,
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 https://braintree.laraship.com/ , you can use a function called getLatestPosts({number of posts}) for example

    @isset($home)
        <!-- ******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 }}"/>
                                    </a>
                                </figure>
                                <div class="content-wrapper text-center">
                                    <h3 class="sub-title"><a href="{{ url($post->slug) }}">{{ $post->title }}</a></h3>
                                    <div class="desc">
                                        <p>
                                            {{ str_limit(strip_tags($post->rendered )) }}
                                        </p>
                                    </div><!--//desc-->
                                </div><!--//content-wrapper text-center-->
                            </div><!--//item-inner-->
                        </div><!--//item-->
                    @endforeach
                </div><!--//row-->
            </div><!--//container-->
        </section><!--//latest-blog-->
    @endisset
Arif Hidyawan replied 5 years ago

Awesome… Thank you!

laraship Staff replied 5 years ago

🙂