Skip to content

Instantly share code, notes, and snippets.



Last active Dec 11, 2015
What would you like to do?
// sfw endpoint
add_action( 'init', 'add_sfw_endpoint' );
function add_sfw_endpoint()
add_rewrite_endpoint( 'sfw', EP_ALL );
add_action( 'pre_get_posts', 'sfw_pre_get_posts' );
function sfw_pre_get_posts($query)
global $wp_query;
if (isset($wp_query->query_vars['sfw']))
$query->query_vars['tax_query'][] = array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => 'nsfw',
'operator' => 'NOT IN',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.