Created
November 13, 2014 20:41
-
-
Save n7studios/ec9740823ee326092754 to your computer and use it in GitHub Desktop.
Soliloquy - Featured Content - Exclude Taxonomy Terms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Soliloquy - Featured Content - Exclude Terms | |
* Plugin URI: http://soliloquywp.com | |
* Version: 1.0 | |
* Author: Tim Carr | |
* Author URI: http://www.n7studios.co.uk | |
* Description: Excludes specific terms from inclusion in Featured Content sliders | |
*/ | |
/** | |
* Start the slider based on the supplied index | |
* | |
* @param array $data Slider Data | |
* @param int $sliderID Slider ID | |
* @return array Slider Data | |
*/ | |
function soliloquy_fc_exclude_terms( $query_args, $id, $data ) { | |
// Start config | |
$sliderToFilter = 69; // Soliloquy slider ID to apply exclusions to | |
$taxonomy = 'category'; | |
$taxonomyTermsToExclude = array( | |
'ignoreme', // Slug of the category you want to exclude | |
'another-category-to-ignore', // Another slug of a category you want to exclude | |
); | |
// End config | |
// Check slider ID is one you want to filter | |
if ( $id != $sliderToFilter ) { | |
return $query_args; | |
} | |
// Add exclusions to query | |
$query_args['tax_query'][] = array( | |
'taxonomy' => $taxonomy, | |
'field' => 'slug', | |
'terms' => $taxonomyTermsToExclude, | |
'operator' => 'NOT IN', | |
); | |
return $query_args; | |
} | |
add_filter( 'soliloquy_fc_query_args', 'soliloquy_fc_exclude_terms', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment