How to make CPTUI-Extended show posts with any of selected terms instead of all selected terms.

CPTUI-Extended offers the ability to select various taxonomy terms when setting up some shortcodes. When you choose some terms, the results will only have posts that have every selected terms. That may be exactly what you want, but what if it is not? What if you want a list of results that have any of the selected terms, but not all?

If you want to change this behavior, add the following code to your active theme’s functions.php file or a custom plugin.

function cptuiext_return_or_relation() {
    return 'OR';
add_filter( 'cptui_tax_query_relation', 'cptuiext_return_or_relation' );

The snippet will return the “OR” keyword to the code and will make it choose posts that have any of the terms. By default “AND” is used, making the query more restrictive.