Help Center

How to Filter the Posts Using Custom Fields Values

Learn how to filter posts by custom field values using the JetBlog plugin for WordPress.

Before you start, check the tutorial requirements:

Things to know

This feature allows displaying only posts that contain the specific information. This can be accomplished using categories, but it won't help when querying posts by specific values. In order to achieve such a feat, you'd need to use the special functionality of JetBlog widgets, allowing you to filter the posts using the values from the meta fields. We described the custom fields, including all details, in the How to Display the Content From Meta Fields in Smart Posts List and Posts Tiles Widgets tutorial.

Configure the Posts Settings

Currently, the Custom Fields can be added to a post via the Post Options or the site’s database.

Add the Custom Fields via the Post Options

Open the needed post in the WordPress Dashboard > Posts > All Posts tab and click the “three dots” button in the upper-right corner. Here, move to the bottom of the settings window and press the Preferences tab. 

Next, move to the bottom of the newly appeared Preferences pop-up and enable the Custom Fields toggle in the Advanced section.

enabling the custom fields for posts

After that, the pop-up will disappear, and a list of custom fields will appear below the post’s fields. Scroll the page until you reach the Custom Field block.

Below, you will see the block named “Add New Custom Field“. In the drop-down, select the Name and enter the post’s Value to be shown.

adding the custom field values

Finally, save the post by pressing the “Save” button at the top of the page.

Add the Custom Field via the site database

To add value, you need to access the site’s database using the appropriate tools (e.g., phpMyAdmin). Then select the wp_postmeta table and look for the meta_key field to choose the appropriate key.

the wp_postmeta table in the site’s database

Configure the Filter Settings

Things to know

Note that multiple values can be selected at once. Default values are applied if nothing else is chosen.

Enable the JetBlog widgets

Move to the WordPress Dashboard > Crocoblock > JetPlugins Settings tab. Here, the JetBlog settings are displayed. Unroll the Available Widgets tab and enable the Smart Posts List or Smart Tiles List widgets.

the jetblog available widgets tab

Once enabled, the changes will be saved automatically.

Add the widgets to a page

Open a page and insert the Smart Posts List or Smart Tiles List widget on the page. Here, the posts will be displayed and arranged by default.

the smart posts list widget inserted on a page

After that, choose the needed section and proceed to the Content > Query & Control tab.

Toggle on the Filter by Custom Fields option.

In the Custom Fields Key field, you have to add the corresponding field’s name.

The next field is Custom Fields Value, where you can query posts by the specific value of the custom field.

the filter by custom field toggle enabled

Below, you can turn on the filter by Terms: Categories, etc.

That’s all about filtering posts by custom field values using the JetBlog plugin for WordPress.

Was this article helpful?
YesNo

Need help?

Ask Facebook community

Get answers from 30K+ Crocoblock Community experts from all over the world.

Start a live chat

Ask question to support agent and share its details via chat messages.