Support

Account

Home Forums General Issues Custom field filter for archive page

Solved

Custom field filter for archive page

  • I am absolutely beginner to PHP and looking for some help. I am trying to create a restaurant directory where I was able to get the output to display under each post in category page using:
    Options: <?php echo implode(' | ', get_field('field_options')); ?>

    I am using below acf (checkboxes)
    Options:
    out : Outdoor
    wifi : WIFI Available
    smoke : Smoking Area

    Now all I need is to add a group of checkbox fields to my category page to filter the posts by above options.

    I tried to follow “Creating a WP archive with custom field filter” tutorial but the method used was radio buttons.

    I would really appreciative if I can know what exactly to put in function.php file and category.php file.

    Attached image will tell you what exactly I am trying to achieve.

  • Hi @uakz

    Creating a checkbox input is very similar to creating a radio input. Please checkout some online tutorials to learn more about this.

    I would love to help, but this question is far from a support issue, so I am unable to pride any support for this.

    Good luck creating your custom page, and please feel free to ask any specific ACF related questions.

    Thanks
    E

  • This reply has been marked as private.
  • Hi @uakz

    The tutorial in question shows a lot of complicated code, which I do no offer my services to login and debug.

    Please debug your code line by line to ensure all variables and values are as expected.

    Many plugins / theme code can modify and cause issues with the posts returned by a WP_Query, so perhaps it is possible that another source is causing no posts to be found.

    Most likely, it is a logic error in the code you have written that is causing the WP_Query to find no posts.

    Thanks
    E

  • Thanks Elliot,

    I did a clean install and everything seems to be working now. Please help me with only one thing.

    I replaced radio buttons to check boxes from ACF, resulting, I can choose more than one bedroom for a house.

    For example, I have
    House 1 : Checkbox 1 selected
    House 2 : Checkbox 2 selected
    House 3 : Checkbox 3 and checkbox 1 selected

    Now form archive page, when I select checkbox 1, I only see House 1, where I should be getting House 3 as well.

    Could you be kind enough to tell me where/what to add/replace the code?

    Thanks

  • Hi @uakz

    Sorry, but I am unavailable for these kinds of questions. I’m glad you have got your code working, but you will need to write the custom logic yourself.

    Thanks
    E

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

The topic ‘Custom field filter for archive page’ is closed to new replies.