0

I"m tryign to get the search count: example:

X result are found for 'keyword'

I don't know much about Twig and Im struggling;

below is my search result page, which display the search result correctly:

{% set lightordark = 'light' %}

{% extends "templates/base.twig"     %}

{% block content %}

<div id="search-single">
<section id="hero_block" class="fcontainer" style="background-image: url('{{ function('get_template_directory_uri', '/') }}/assets/images/HeroSearchResult.jpg')">
        <div class="inner_wrapper">
            <div class="block top">
                   <h1 class="hero_block_text">Looking for something ?
                  </h1>

                <div class="gcontainer">
                {{ function('do_shortcode', '[wpdreams_ajaxsearchlite]') }}
                </div>

            </div>
        </div>
    </section>

    <section class="gcontainer">

        <div class="inner_wrapper">
            <div class="block hundred">

                {% if posts|length == 0 %}
                    <h3>{{ __('Sorry, no results were found.', 'sage') }}</h3>

                {% else %}


  <h2 class="pagetitle">
  </h2>

                    {% for result in posts %}

                        <div class="inner_wrapper search_detail" style="text-align: center">

                                <h2><a href="{{ result.link }}">{{ result.post_title }}</a></h2>
                                <p>{{ result.excerpt }}</p>
                                <div class="info_cta" style="text-align: left">
                                    <a class="read_more" href="{{ result.link }}">Read more</a>
                                </div>

                        </div>


                    {% endfor %}

                    {#{% for result in search_results %}#}
                    {#<div class="inner_wrapper search_detail" style="text-align: center">#}
                    {#<div class="block thirty_small">#}
                    {#<img src="{{ result.data.thumbnail_global.sizes.thumbnail }}">#}
                    {#</div>#}
                    {#<div class="block thirty_small">#}
                    {#<h2><a href="{{ result.permalink }}">{{ result.post_title }}</a></h2>#}
                    {#<p>{{ result.data.excerpt }}</p>#}
                    {#<div class="info_cta" style="text-align: left">#}
                    {#<a class="read_more" href="{{ result.permalink }}">Read more</a>#}
                    {#</div>#}
                    {#</div>#}

                    {#</div>#}
                    {#{% endfor %}#}



                {% endif %}
            </div>
        </div>
    </section>
</div>

{% endblock %}

Any help will be incredible ! THanks a lot !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.