Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawkidoki/367af35ed47d732bdc68a4449bd81ac3 to your computer and use it in GitHub Desktop.
Save hawkidoki/367af35ed47d732bdc68a4449bd81ac3 to your computer and use it in GitHub Desktop.
<?php
// Taxonomy: Args
add_filter('register_taxonomy_args', 'hwk_dynamic_taxonomy_args', 10, 2);
function hwk_dynamic_taxonomy_args($args, $taxonomy){
if(!apply_filters('hwk/taxonomy/' . $taxonomy . '/args/no_single', false))
return $args;
if($args['show_ui'] === null)
$args['show_ui'] = true;
if($args['show_in_nav_menus'] === null)
$args['show_in_nav_menus'] = true;
if($args['publicly_queryable'] === null)
$args['publicly_queryable'] = true;
if($args['exclude_from_search'] === null)
$args['exclude_from_search'] = true;
$args['public'] = false;
$args['rewrite'] = false;
return $args;
}
// Taxonomy: Permalink
add_filter('term_link', 'hwk_dynamic_taxonomy_permalink', 10, 3);
function hwk_dynamic_taxonomy_permalink($link, $term, $taxonomy){
if(!apply_filters('hwk/taxonomy/' . $taxonomy . '/args/no_single', false))
return $link;
return home_url();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment