• I want to know if it’s possible to do dynamic filtering of my blog page using buttons located on a different page. So, if I’m on page A, and I have 2 buttons. If I click button A, I want to navigate to my blog page with one filter set. If I click button B, I want to navigate to my blog page with a different filter. Probably filtering by tags in both cases. I know I can filter the blog page using a shortcode, but is there a way to do this dynamically, when starting from a different page in this way?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    It’s possible. The challenge is to get the filter criteria passed from page A to other pages. This will not happen on its own, you need to take measures to make it happen. There are not that many options on how to have data persist from one request to the next. If users are always logged in, their choices can be saved in the DB somewhere and retrieved any time filtering is needed.

    If users might not be logged in, you can either pass the filter criteria in the URL’s query string, or save the criteria in a cookie. It’s also possible to save data in a session variable. Sessions seem to often be problematic in WP, so should maybe be avoided. I suspect the session issue is from it being poorly implemented. It should work when properly implemented.

    The URL query string method can work, but only when following links from your previous pages. If someone navigates from an earlier bookmark, there will be no filter criteria. Or if they bookmark a link with filter criteria, they’ll get filtering whether they wanted it or not.

    Cookies involve privacy issues, but can otherwise be a good solution. You can limit how long filtering is valid by setting cookie expiration. Of course users can change their filter criteria as they wish and the cookie should be updated accordingly.

    Thread Starter ctredwin

    (@ctredwin)

    Thanks – I’ll go with the URL method, I think, and just accept the imitation that users might not see what exactly what they expect from a bookmark.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Dynamic Filtering with buttons’ is closed to new replies.