Filter posts by checkboxes in wordpress (Custom fields from ACF)

As we discussed this in our earlier posts that in wordpress, sometimes we needs to filter the posts. We had done with the filter posts by taxonomy. You can have a look at that tutorial from here. In this tutorial, we will continue to work on the filter. We will “filter posts by checkboxes in wordpress”. The most important part is that we will make the checkbox by using the ACF plugin. If you are familiar with ACF plugin then you can download the plugin from wordpress repository for ACF Plugin.

Now follow these step:

Step 1:

Make the fields with ACF plugin to make checkbox required for the filtering process.

Step 2:

Add the following code into your template file. This code will calls the checkbox into frontend which we hd made using the ACF pluin.

Step 3:

Here we are done with the view part. With the above code, your template is ready with the UI. Now the next task is to make the code working by using the jquery to call the ajax. Copy and paste the following code into your footer.php file or directly into your template:

Step 4:

In the above code, we had called an ajax function “get_keyword_data” . Now we have to make that function into the function.php file of your theme folder.

Filter posts by checkboxes

The above tutorial teach us about the Filter posts by checkboxes in wordpress which is very useful for those who work as wordpress developer.