Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog Portfolio: If Taxonomies are selected, only show those as filter options #2030

Open
AlexGStapleton opened this issue Sep 11, 2024 · 0 comments

Comments

@AlexGStapleton
Copy link
Member

This is currently possible using #2029, but it would be better to alter how the Portfolio template works to allow for this out of the box. Here's a snippet I previously wrote to do this:

add_filter( 'siteorigin_widgets_blog_portfolio_taxonomy', function( $taxonomy, $instance, $post_type ) {
	$posts = wp_parse_args( siteorigin_widget_post_selector_process_query( $instance['posts'] ) );

	if (
		empty( $posts['tax_query'] ) ||
		! is_array( $posts['tax_query'] )
	) {
		return $taxonomy;
	}

	$valid_taxonomies = array();
	foreach ( $posts['tax_query'] as $tax_query ) {
		if ( isset( $tax_query['terms'] ) ) {
			$tax_query['slug'] = sanitize_title( $tax_query['terms'] );
			$valid_taxonomies[] = (object) $tax_query;
		}
	}

	return $valid_taxonomies;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant