3

Below is my paginate code and it's working fine.

{% paginate craft.entries.section('products').limit(9) as entriesOnPage %}

{% for entry in entriesOnPage %}
    <div class="product-box">
        <div class="product">
            <p class="product-name">
                <a href="{{ entry.category.first().url }}">{{ entry.category.first().title }}</a>
            </p>
        </div>
    </div>
{% endfor %}

{% if paginate.nextUrl %}
    <a href="{{ paginate.nextUrl }}">Next</a>
{% endif %}

{% endpaginate %}

Below is my code to display specific category data with pagination. and it's not working.

{% set requestCategory = craft.request.getLastSegment() %}

{% paginate craft.entries.section('products').find({
    search: 'categories:' ~ requestCategory,
  }).limit(9) as entriesOnPage %}

{% for entry in entriesOnPage %}
    <div class="product-box">
        <div class="product">
            <p class="product-name">
                <a href="{{ entry.category.first().url }}">{{ entry.category.first().title }}</a>
            </p>
        </div>
    </div>
{% endfor %}

{% if paginate.nextUrl %}
    <a href="{{ paginate.nextUrl }}">Next</a>
{% endif %}

{% endpaginate %}

i want to add category filter on that but not working how can i add a category filter?

4

Try using the relatedTo() filter as explained here:

http://buildwithcraft.com/help/entries-related-to-category

{% paginate craft.entries.section('products').relatedTo(requestCategory).limit(9) as entriesOnPage %}
|improve this answer|||||

Your Answer

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

Not the answer you're looking for?Browse other questions tagged or ask your own question.