aaron13100 / 404solution

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

404-Redirected seems to break Timber Pagination. #9

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

aaron13100 commented 7 years ago

From @defries on June 20, 2016 9:21

What Timber theme/plugin (?) are you using? If I want to replicate this, I'm going to need a theme that uses timber ...

aaron13100 commented 7 years ago

From @adhorrig on June 20, 2016 9:25

I am using the Timber starter theme: https://github.com/timber/starter-theme.

Plugin Versions:

Timber: v1.0.4. 404-Redirected: v1.4.3. WordPress: v4.5.2.

aaron13100 commented 7 years ago

From @ryanhellyer on June 20, 2016 10:35

I'm not sure what to do with the code provided above. I don't think you intended it to be just put anywhere in the functions.php.

aaron13100 commented 7 years ago

From @adhorrig on June 20, 2016 13:19

It's in function add_to_context($context){...}

aaron13100 commented 7 years ago

From @ryanhellyer on June 29, 2016 13:16

I'll need more information to assist with this. I don't know where to put the HTML within the theme.

aaron13100 commented 7 years ago

From @adhorrig on June 29, 2016 13:27

Hey.

The HTML can go onto any page. I would suggest creating a page in wordpress named 'test'. Then in the theme under views create page-test.twig. You should then be able to navigate to localhost:xxxx/xxxxxx/test. The HTML would go into the page-test.twig.

Need any more information? 😃

aaron13100 commented 7 years ago

This is no longer related to ThemeMix/redirectioner so I'm closing this and creating a new ticket.