WordPress.org

Support

Support » Plugins and Hacks » Hacks » User defined visibility of categories based on check boxes

User defined visibility of categories based on check boxes

  • Hi All,

    This is my first post and first time working with Word Press so here goes.

    I am in the process of modifying a friends site so that a user can choose categories via check boxes on the main home page so then the posts showing will reflect their choice.

    So far, I have modified the header to include the check boxes and code needed to save the selections back to a cookie so that they can be reloaded when the visitor next returns.

    The part I am stuck on is now how to filter the page based on the check box values. I was going to use the values from the check boxes to choose category id’s but when I started to look at the built in wp_query documentation but it looks like its php based and obviously, being server side and my controls being on the client side, I can’t work out how to ‘drive’ the filter.

    And guidance would be greatly received as I think I am heading towards a dead end.

    Thanks in advance,

    James

Viewing 1 replies (of 1 total)
  • The checkbox states need to be sent back to the server so it can do a new query based on the selected categories. The new query results are then sent out to the client as a new page.

    If you submit the checkbox form as a GET request, the selections should get parsed into query variables OK, but the query parser will not know what to do with them, You will need to hook the ‘pre_get_posts’ filter to interpret the checkbox states into something the query parser will understand. Once you do this, WP will properly fill the request with an appropriately filtered new page.

Viewing 1 replies (of 1 total)
  • The topic ‘User defined visibility of categories based on check boxes’ is closed to new replies.