We're offering a free six-month trial of Hookline: Atmos - a plugin that adds a Gravity Forms element for Oxygen Builder. Get it today!

Getting the Current Archive Information for an Oxygen Repeater

When creating an Archive template in Oxygen, you may often want to use an Advanced Query. However, when using an Advanced Query, the query is changed and therefore loses its natural filtering for getting the current archive information, such as the current taxonomy and term.

To fix this, we can add two functions to your site using your preferred code snippets plugin, like WP Code Box.

/**
 * Get the current term
 * 
 * @return string $current_terms - the current term
 */
if (!function_exists('bitt_current_archive_term')) {

    function bitt_current_archive_term()
    {
        $current_terms = get_queried_object()->term_id;
        return $current_terms;
    }
}

/**
 * Get the current taxonomy
 * 
 * @return string $current_taxonomy - the current taxonomy
 */
if (!function_exists('bitt_current_archive_taxonomy')) {

    function bitt_current_archive_taxonomy()
    {
        $current_taxonomy = get_queried_object()->taxonomy;
        return $current_taxonomy;
    }
}

These snippets can also be found here:

With these functions added, we can now update our Advanced Query to use the current archive information. Within the Advanced Query, add the “tax_query” parameter and a new array.

Then, add the following values to the array:

  • taxonomy = PHP Function Return value of “bitt_current_archive_taxonomy”.
  • field = “id”
  • terms = PHP Function Return value of “bitt_current_archive_term”.

With this setup, we can add additional parameters to the Advanced Query, such as what post types should be returned, how many posts per page, or anything else you’d like to include from WP_Query.

    Leave a Reply

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

    © 2020-2023 Luxibay
    Name(Required)
    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.

    %d bloggers like this: