I am trying to get pagination in product listing page according to current/selected category using...












0















Archive.php

I have used timber query here. Am open to all suggestions. Following is the php code for archive page. I have used timber query here. Am open to all suggestions. Following is the php code for archive page.



    $templates = array( 'archive.twig', 'index.twig' );
$context = Timber::get_context();
if ( is_day() ) {
$context['title'] = 'Archive: ' . get_the_date( 'D M Y' );
} else if ( is_month() ) {
$context['title'] = 'Archive: ' . get_the_date( 'M Y' );
} else if ( is_year() ) {
$context['title'] = 'Archive: ' . get_the_date( 'Y' );
} else if ( is_tag() ) {
$context['title'] = single_tag_title( '', false );
} else if ( is_category() ) {
$context['title'] = single_cat_title( '', false );
array_unshift( $templates, 'archive-' . get_query_var( 'cat' ) . '.twig' );
} else if ( is_post_type_archive() ) {
$context['title'] = post_type_archive_title( '', false );
array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
}

$context['title'] = 'Archive';
$context['term_page'] = new TimberTerm();
$context['posts'] = new TimberPostQuery();
$context['footer_left'] = Timber::get_widgets('footer_left');
$context['footer_center'] = Timber::get_widgets('footer_center');
$context['footer_right'] = Timber::get_widgets('footer_right');
$context['lang_bar'] = Timber::get_widgets('lang_bar');
$context['header_menu'] = Timber::get_widgets('header_menu');
$context['options'] = get_fields('options');

Timber::render( $templates, $context );


Archive.twig

I have used twig template here. Am open to all suggestions. Following is the twig code for archive template page. This is the listing page for products with specific category.



    {% extends "headerArchive.twig" %}

{% block content%}

{% for post in posts %}
{% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
{% endfor %}
{% endblock %}


tease-product.twig

I have used twig template here. Am open to all suggestions. Following is the twig code for single product information page. This is the product template for listing page with specific category.



    <div class="veg_product_details">
<div class="veg_product_blog_content">
<div class="veg_1">
<div class="col-sm-6 left_padding_0">
<div class="veg_img">
<img src="{{post.thumbnail.src}}" alt="product" class="img-responsive">
</div>
</div>
<div class="col-sm-6">
<div class="veg_details">
<h3>{{post.title}}</h3>
<p>{{post.preview[:50]}}</p>

<div class="veg_item_btn">
<div class="pull-left">
<a class="btn view_btn veg_btn" href="{{post.link}}">View Details</a>
</div>
<div class="pull-right">
<img src="{{theme.link}}/templates/images//veg_logo.png" class="img-responsive margin_img" alt="logo">
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>


pagination.twig



    {% if posts.pagination.pages is not empty %}
<nav class="pagination-block">
<ul class="pagination">
{% if pagination.pages|first and pagination.pages|first.current != true %}
<li class="first btn">
<a href="{{ pagination.pages|first.link }}">First</a>
</li>
{% else %}
<li class="first btn disabled">
<button disabled>First</button>
</li>
{% endif %}

{% if pagination.prev %}
<li class="prev btn">
<a href="{{ pagination.prev.link }}">Previous</a>
</li>
{% else %}
<li class="prev btn disabled">
<button disabled>Previous</button>
</li>
{% endif %}

{% for page in pagination.pages %}
{% if page.link %}
<li>
<a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a>
</li>
{% else %}
<li class="current">
<span class="{{ page.class }}">{{ page.title }}</span>
</li>
{% endif %}
{% endfor %}

{% if pagination.next %}
<li class="next btn">
<a href="{{ pagination.next.link }}">
Next
</a>
</li>
{% else %}
<li class="next btn disabled">
<button disabled>
Next
</button>
</li>
{% endif %}
{% if pagination.pages|last and pagination.pages|last.current != true %}
<li class="last btn">
<a href="{{ pagination.pages|last.link }}">Last</a>
</li>
{% else %}
<li class="last btn disabled">
<button disabled>Last</button>
</li>
{% endif %}
</ul>
</nav>
{% endif %}


I want pagination on my product category listing page. I am getting another issue. When I'm navigating into next page [url: myserverurl/product-category/poultry/page/2], no data is showing and 404 page is showing up. How do I solve all these issues?










share|improve this question





























    0















    Archive.php

    I have used timber query here. Am open to all suggestions. Following is the php code for archive page. I have used timber query here. Am open to all suggestions. Following is the php code for archive page.



        $templates = array( 'archive.twig', 'index.twig' );
    $context = Timber::get_context();
    if ( is_day() ) {
    $context['title'] = 'Archive: ' . get_the_date( 'D M Y' );
    } else if ( is_month() ) {
    $context['title'] = 'Archive: ' . get_the_date( 'M Y' );
    } else if ( is_year() ) {
    $context['title'] = 'Archive: ' . get_the_date( 'Y' );
    } else if ( is_tag() ) {
    $context['title'] = single_tag_title( '', false );
    } else if ( is_category() ) {
    $context['title'] = single_cat_title( '', false );
    array_unshift( $templates, 'archive-' . get_query_var( 'cat' ) . '.twig' );
    } else if ( is_post_type_archive() ) {
    $context['title'] = post_type_archive_title( '', false );
    array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
    }

    $context['title'] = 'Archive';
    $context['term_page'] = new TimberTerm();
    $context['posts'] = new TimberPostQuery();
    $context['footer_left'] = Timber::get_widgets('footer_left');
    $context['footer_center'] = Timber::get_widgets('footer_center');
    $context['footer_right'] = Timber::get_widgets('footer_right');
    $context['lang_bar'] = Timber::get_widgets('lang_bar');
    $context['header_menu'] = Timber::get_widgets('header_menu');
    $context['options'] = get_fields('options');

    Timber::render( $templates, $context );


    Archive.twig

    I have used twig template here. Am open to all suggestions. Following is the twig code for archive template page. This is the listing page for products with specific category.



        {% extends "headerArchive.twig" %}

    {% block content%}

    {% for post in posts %}
    {% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
    {% endfor %}
    {% endblock %}


    tease-product.twig

    I have used twig template here. Am open to all suggestions. Following is the twig code for single product information page. This is the product template for listing page with specific category.



        <div class="veg_product_details">
    <div class="veg_product_blog_content">
    <div class="veg_1">
    <div class="col-sm-6 left_padding_0">
    <div class="veg_img">
    <img src="{{post.thumbnail.src}}" alt="product" class="img-responsive">
    </div>
    </div>
    <div class="col-sm-6">
    <div class="veg_details">
    <h3>{{post.title}}</h3>
    <p>{{post.preview[:50]}}</p>

    <div class="veg_item_btn">
    <div class="pull-left">
    <a class="btn view_btn veg_btn" href="{{post.link}}">View Details</a>
    </div>
    <div class="pull-right">
    <img src="{{theme.link}}/templates/images//veg_logo.png" class="img-responsive margin_img" alt="logo">
    </div>
    </div>
    <div class="clearfix"></div>
    </div>
    </div>
    <div class="clearfix"></div>
    </div>
    </div>
    </div>


    pagination.twig



        {% if posts.pagination.pages is not empty %}
    <nav class="pagination-block">
    <ul class="pagination">
    {% if pagination.pages|first and pagination.pages|first.current != true %}
    <li class="first btn">
    <a href="{{ pagination.pages|first.link }}">First</a>
    </li>
    {% else %}
    <li class="first btn disabled">
    <button disabled>First</button>
    </li>
    {% endif %}

    {% if pagination.prev %}
    <li class="prev btn">
    <a href="{{ pagination.prev.link }}">Previous</a>
    </li>
    {% else %}
    <li class="prev btn disabled">
    <button disabled>Previous</button>
    </li>
    {% endif %}

    {% for page in pagination.pages %}
    {% if page.link %}
    <li>
    <a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a>
    </li>
    {% else %}
    <li class="current">
    <span class="{{ page.class }}">{{ page.title }}</span>
    </li>
    {% endif %}
    {% endfor %}

    {% if pagination.next %}
    <li class="next btn">
    <a href="{{ pagination.next.link }}">
    Next
    </a>
    </li>
    {% else %}
    <li class="next btn disabled">
    <button disabled>
    Next
    </button>
    </li>
    {% endif %}
    {% if pagination.pages|last and pagination.pages|last.current != true %}
    <li class="last btn">
    <a href="{{ pagination.pages|last.link }}">Last</a>
    </li>
    {% else %}
    <li class="last btn disabled">
    <button disabled>Last</button>
    </li>
    {% endif %}
    </ul>
    </nav>
    {% endif %}


    I want pagination on my product category listing page. I am getting another issue. When I'm navigating into next page [url: myserverurl/product-category/poultry/page/2], no data is showing and 404 page is showing up. How do I solve all these issues?










    share|improve this question



























      0












      0








      0








      Archive.php

      I have used timber query here. Am open to all suggestions. Following is the php code for archive page. I have used timber query here. Am open to all suggestions. Following is the php code for archive page.



          $templates = array( 'archive.twig', 'index.twig' );
      $context = Timber::get_context();
      if ( is_day() ) {
      $context['title'] = 'Archive: ' . get_the_date( 'D M Y' );
      } else if ( is_month() ) {
      $context['title'] = 'Archive: ' . get_the_date( 'M Y' );
      } else if ( is_year() ) {
      $context['title'] = 'Archive: ' . get_the_date( 'Y' );
      } else if ( is_tag() ) {
      $context['title'] = single_tag_title( '', false );
      } else if ( is_category() ) {
      $context['title'] = single_cat_title( '', false );
      array_unshift( $templates, 'archive-' . get_query_var( 'cat' ) . '.twig' );
      } else if ( is_post_type_archive() ) {
      $context['title'] = post_type_archive_title( '', false );
      array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
      }

      $context['title'] = 'Archive';
      $context['term_page'] = new TimberTerm();
      $context['posts'] = new TimberPostQuery();
      $context['footer_left'] = Timber::get_widgets('footer_left');
      $context['footer_center'] = Timber::get_widgets('footer_center');
      $context['footer_right'] = Timber::get_widgets('footer_right');
      $context['lang_bar'] = Timber::get_widgets('lang_bar');
      $context['header_menu'] = Timber::get_widgets('header_menu');
      $context['options'] = get_fields('options');

      Timber::render( $templates, $context );


      Archive.twig

      I have used twig template here. Am open to all suggestions. Following is the twig code for archive template page. This is the listing page for products with specific category.



          {% extends "headerArchive.twig" %}

      {% block content%}

      {% for post in posts %}
      {% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
      {% endfor %}
      {% endblock %}


      tease-product.twig

      I have used twig template here. Am open to all suggestions. Following is the twig code for single product information page. This is the product template for listing page with specific category.



          <div class="veg_product_details">
      <div class="veg_product_blog_content">
      <div class="veg_1">
      <div class="col-sm-6 left_padding_0">
      <div class="veg_img">
      <img src="{{post.thumbnail.src}}" alt="product" class="img-responsive">
      </div>
      </div>
      <div class="col-sm-6">
      <div class="veg_details">
      <h3>{{post.title}}</h3>
      <p>{{post.preview[:50]}}</p>

      <div class="veg_item_btn">
      <div class="pull-left">
      <a class="btn view_btn veg_btn" href="{{post.link}}">View Details</a>
      </div>
      <div class="pull-right">
      <img src="{{theme.link}}/templates/images//veg_logo.png" class="img-responsive margin_img" alt="logo">
      </div>
      </div>
      <div class="clearfix"></div>
      </div>
      </div>
      <div class="clearfix"></div>
      </div>
      </div>
      </div>


      pagination.twig



          {% if posts.pagination.pages is not empty %}
      <nav class="pagination-block">
      <ul class="pagination">
      {% if pagination.pages|first and pagination.pages|first.current != true %}
      <li class="first btn">
      <a href="{{ pagination.pages|first.link }}">First</a>
      </li>
      {% else %}
      <li class="first btn disabled">
      <button disabled>First</button>
      </li>
      {% endif %}

      {% if pagination.prev %}
      <li class="prev btn">
      <a href="{{ pagination.prev.link }}">Previous</a>
      </li>
      {% else %}
      <li class="prev btn disabled">
      <button disabled>Previous</button>
      </li>
      {% endif %}

      {% for page in pagination.pages %}
      {% if page.link %}
      <li>
      <a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a>
      </li>
      {% else %}
      <li class="current">
      <span class="{{ page.class }}">{{ page.title }}</span>
      </li>
      {% endif %}
      {% endfor %}

      {% if pagination.next %}
      <li class="next btn">
      <a href="{{ pagination.next.link }}">
      Next
      </a>
      </li>
      {% else %}
      <li class="next btn disabled">
      <button disabled>
      Next
      </button>
      </li>
      {% endif %}
      {% if pagination.pages|last and pagination.pages|last.current != true %}
      <li class="last btn">
      <a href="{{ pagination.pages|last.link }}">Last</a>
      </li>
      {% else %}
      <li class="last btn disabled">
      <button disabled>Last</button>
      </li>
      {% endif %}
      </ul>
      </nav>
      {% endif %}


      I want pagination on my product category listing page. I am getting another issue. When I'm navigating into next page [url: myserverurl/product-category/poultry/page/2], no data is showing and 404 page is showing up. How do I solve all these issues?










      share|improve this question
















      Archive.php

      I have used timber query here. Am open to all suggestions. Following is the php code for archive page. I have used timber query here. Am open to all suggestions. Following is the php code for archive page.



          $templates = array( 'archive.twig', 'index.twig' );
      $context = Timber::get_context();
      if ( is_day() ) {
      $context['title'] = 'Archive: ' . get_the_date( 'D M Y' );
      } else if ( is_month() ) {
      $context['title'] = 'Archive: ' . get_the_date( 'M Y' );
      } else if ( is_year() ) {
      $context['title'] = 'Archive: ' . get_the_date( 'Y' );
      } else if ( is_tag() ) {
      $context['title'] = single_tag_title( '', false );
      } else if ( is_category() ) {
      $context['title'] = single_cat_title( '', false );
      array_unshift( $templates, 'archive-' . get_query_var( 'cat' ) . '.twig' );
      } else if ( is_post_type_archive() ) {
      $context['title'] = post_type_archive_title( '', false );
      array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
      }

      $context['title'] = 'Archive';
      $context['term_page'] = new TimberTerm();
      $context['posts'] = new TimberPostQuery();
      $context['footer_left'] = Timber::get_widgets('footer_left');
      $context['footer_center'] = Timber::get_widgets('footer_center');
      $context['footer_right'] = Timber::get_widgets('footer_right');
      $context['lang_bar'] = Timber::get_widgets('lang_bar');
      $context['header_menu'] = Timber::get_widgets('header_menu');
      $context['options'] = get_fields('options');

      Timber::render( $templates, $context );


      Archive.twig

      I have used twig template here. Am open to all suggestions. Following is the twig code for archive template page. This is the listing page for products with specific category.



          {% extends "headerArchive.twig" %}

      {% block content%}

      {% for post in posts %}
      {% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
      {% endfor %}
      {% endblock %}


      tease-product.twig

      I have used twig template here. Am open to all suggestions. Following is the twig code for single product information page. This is the product template for listing page with specific category.



          <div class="veg_product_details">
      <div class="veg_product_blog_content">
      <div class="veg_1">
      <div class="col-sm-6 left_padding_0">
      <div class="veg_img">
      <img src="{{post.thumbnail.src}}" alt="product" class="img-responsive">
      </div>
      </div>
      <div class="col-sm-6">
      <div class="veg_details">
      <h3>{{post.title}}</h3>
      <p>{{post.preview[:50]}}</p>

      <div class="veg_item_btn">
      <div class="pull-left">
      <a class="btn view_btn veg_btn" href="{{post.link}}">View Details</a>
      </div>
      <div class="pull-right">
      <img src="{{theme.link}}/templates/images//veg_logo.png" class="img-responsive margin_img" alt="logo">
      </div>
      </div>
      <div class="clearfix"></div>
      </div>
      </div>
      <div class="clearfix"></div>
      </div>
      </div>
      </div>


      pagination.twig



          {% if posts.pagination.pages is not empty %}
      <nav class="pagination-block">
      <ul class="pagination">
      {% if pagination.pages|first and pagination.pages|first.current != true %}
      <li class="first btn">
      <a href="{{ pagination.pages|first.link }}">First</a>
      </li>
      {% else %}
      <li class="first btn disabled">
      <button disabled>First</button>
      </li>
      {% endif %}

      {% if pagination.prev %}
      <li class="prev btn">
      <a href="{{ pagination.prev.link }}">Previous</a>
      </li>
      {% else %}
      <li class="prev btn disabled">
      <button disabled>Previous</button>
      </li>
      {% endif %}

      {% for page in pagination.pages %}
      {% if page.link %}
      <li>
      <a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a>
      </li>
      {% else %}
      <li class="current">
      <span class="{{ page.class }}">{{ page.title }}</span>
      </li>
      {% endif %}
      {% endfor %}

      {% if pagination.next %}
      <li class="next btn">
      <a href="{{ pagination.next.link }}">
      Next
      </a>
      </li>
      {% else %}
      <li class="next btn disabled">
      <button disabled>
      Next
      </button>
      </li>
      {% endif %}
      {% if pagination.pages|last and pagination.pages|last.current != true %}
      <li class="last btn">
      <a href="{{ pagination.pages|last.link }}">Last</a>
      </li>
      {% else %}
      <li class="last btn disabled">
      <button disabled>Last</button>
      </li>
      {% endif %}
      </ul>
      </nav>
      {% endif %}


      I want pagination on my product category listing page. I am getting another issue. When I'm navigating into next page [url: myserverurl/product-category/poultry/page/2], no data is showing and 404 page is showing up. How do I solve all these issues?







      wordpress pagination categories archive timber






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 7:06







      Subhankar Paul

















      asked Nov 16 '18 at 7:01









      Subhankar PaulSubhankar Paul

      12




      12
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332933%2fi-am-trying-to-get-pagination-in-product-listing-page-according-to-current-selec%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332933%2fi-am-trying-to-get-pagination-in-product-listing-page-according-to-current-selec%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          The Sandy Post

          Danny Elfman

          Pages that link to "Head v. Amoskeag Manufacturing Co."