aaron13100 / 404solution

404 Solution
https://ajexperience.com/wealthpsychology/404-solution/
4 stars 2 forks source link

Timber Pagination compatibility #16

Closed aaron13100 closed 7 years ago

aaron13100 commented 7 years ago

From @adhorrig on June 20, 2016 9:18

What I Expected To Happen

I expected the Timber Pagination to work as normal - as it does when 404-Redirected is not activated.

What Happened Instead

404-Redirect does not acknowledge the pagination but instead redirects me back to the initial page. I.e. if I am on 'http://localhost:8888/cd-wordpress/news/' and click 'Next' at the end of the list of posts, I'm redirected to 'http://localhost:8888/cd-wordpress/news/' - the same page. I expect to be redirected to 'http://localhost:8888/cd-wordpress/news/page/2'.

Steps to Reproduce the Bug

Activate Timber and set up Pagination i.e. - functions.php:

    global $paged;
    if (!isset($paged) || !$paged){
        $paged = 1;
    }

    $args = array(
        'posts_per_page' => 10,
        'paged' => $paged
    );

    query_posts($args);
    $context['posts'] = Timber::get_posts();
    $context['pagination'] = Timber::get_pagination();

And then HTML:

{% for post in posts %}
    <li class="article-pagination">
        {% if post.link %}
        <img src="{{post.thumbnail.src}}"/>
        <a href="{{post.link}}" class="{{post.class}}">{{post.title}}</a>
    </li>
{% endfor %}
    </ul>
    {% if pagination.prev %}
     <a href="{{pagination.prev.link}}" class="prev {{pagination.prev.link|length ? '' : 'invisible'}}"><button class="btn btn-default">Previous</button></a>
    {% endif %}
    {% if pagination.next %}
     <a href="{{pagination.next.link}}" class="next {{pagination.next.link|length ? '' : 'invisible'}}">   <button class="btn btn-default">Next</button></a>
    {% endif %}

Test out the pagination, then activate 404-Redirected and try again. You should experience what I describe above.

_Copied from original issue: ThemeMix/redirectioner number eleven