Support

Account

Home Forums General Issues filtering by custom field entry

Solved

filtering by custom field entry

  • i want to filter some custom post types with ajax or jquery.
    i have 4 pages with some custom fields:

    1 – blue / green
    2 – red /green / black
    3 – yellow / black
    4 – yellow

    on the page (frontend) i need to filter it this way (select-boxes):

    first all 4 pages are visible. when i click the checkbox “green” the pages 3 and 4 disappear. then i click the checkbox “blue” and page 2 disappears, too. then i click “yellow” and all pages are gone because there is no page with the custom field entrys “green + blue + yellow”.

    any idea? searched the web up and down but found nothing, only scripts where page 3 + 4 were visible at least because they only check the last option …

  • Hi @herrfischer

    This is what you need to do:

    1. Create a select field with the options
    2. Write some jQuery to trigger a function on change of this select
    3. Get the JS function to do an AJAX call to a WP ajax function
    4. Create this WP ajax function in your functions.php
    5. Get your JS to post the selected value to the php function
    6. Get your php function to use this value to filter the posts and return the correct data
    7. Get your js function to use this data on complete.

    You will find a tutorial in the docs on querying the posts based on a custom field value, the rest is up to you and google.

    Thanks
    E

  • thx elliot,
    now i used this:
    http://luis-almeida.github.io/filtrify/

    with custom fields. awesome 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘filtering by custom field entry’ is closed to new replies.