public
Last active

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// 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',
);
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.