function bitt_acf_taxonomy()

Filter Posts by Post Objects field in an ACF Repeater on a Taxonomy archive based on an ACF taxonomy field:

Ensure the Post Objects ACF field returns the Post Object, not the Post ID.

Next, add the following parameter to an Advanced Query in Oxygen:

  • parameter: post__in

For the value, select PHP Function Return Value > ‘bitt_acf_taxonomy` and set the arguments to the slug of the Repeater field and the slug of the Post Objects field,

function Code

 * ACF Taxonomy Field
 * @param string $tax - taxonomy name (e.g. 'product_taxonomy') 
 * @param string $relationship - relationship name (e.g. 'product_taxonomy_to_product')
 * @return string $results - comma separated list of taxonomy IDs (e.g. '1,2,3')
if (!function_exists('bitt_acf_taxonomy')) {

    function bitt_acf_taxonomy()

        // If ACF is deactivated, return nothing
        if (!class_exists('acf')) {
            return '';

        $terms = get_field('product_taxonomy');

        $term_list = array();
        if ($terms) {

            foreach ($terms as $term) {

                array_push($term_list, $term->term_id);


        $results = implode(',', $term_list);
        return $results;
Leave a Reply

Your email address will not be published. Required fields are marked *

    Table Of Contents

    Related Content

    © 2020-2024 Luxibay
    Please let us know what's on your mind. Have a question for us? Ask away.
    This field is for validation purposes and should be left unchanged.