Published on Sep 22, 2020

Filtering Posts by Taxonomy Terms in Oxygen

Sridhar Katakam

This members-only tutorial provides the steps to limit the posts output by a Oxygen's Easy Posts or Repeater component on singular entries of another post type to only those that belong to the terms selected using ACF's Taxonomy custom field.

Sample Scenario:

tutor Custom Post Type uses the standard WordPress categories Ex.: Maths, Science, Geography.

Advanced Custom Fields field group has a tutor_category_selector custom field of type Taxonomy set to appear on regular Posts.

When editing a Post, Maths and Science are ticked.

The objective is to show a section on singular posts that shows all the tutors that are filtered by the selected categories.

Step 1

If you have not already, register your CPT using a plugin like CPT UI or otherwise, tick support for categories and add a few entries while setting some categories.

Step 2

Add your field group.

Adding a custom field group having a Taxonomy type of field

Leave the Return Value as Term ID.

Step 3

In your post edit screens, select the taxonomy terms that the current post should be "related to".

Step 4

Edit the Oxygen Template that applies to singular posts.

Add a Section.

Add a Easy Posts or Repeater.

Set to Query to custom (or manual, if you prefer that) and select/set your Post Type and optionally, the Count or posts_per_page.

Add a Code Block above the Easy Posts/Repeater.

PHP & HTML:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $499 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right