Ordering terms whilst in loop

I just realised I already have the parent from here $category = $_GET[‘category’]; So I changed my code: <td class=”custom-cat”> <span class=”term”> <?php echo $category; ?> </span></td> <td class=”custom-sub-cat”> <span class=”term”> <?php $terms = get_the_terms( get_the_ID(), ‘custom-category’ ); foreach ( $terms as $term ){ if ( $term->parent ==! 0 ) { echo $term->name; } } … Read more

Restrict product tags archive to certain users

You could setup a redirect at the top of the archive page template for users that don’t match your criteria, something like: $user = wp_get_current_user(); $allowed = array( ‘editor’, ‘administrator’ ); $redirect_url=”https://url-to-redirect-to”; if ( ! $user || ! array_intersect( $allowed, $user->roles ) ) { wp_safe_redirect( $redirect_url, 401 ); exit; } The check for $allowed and … Read more

How to display custom taxonomy term specific post?

Refer Link for Your Knowledge Template Hiearchy for a more detailed break down of how WordPress chooses the template For a taxonomy term slug (‘sports’ your example) in the taxonomy (e.g. ‘News’) WordPress will try to use the following templates (in this order) taxonomy-{taxonomy}-{slug}.php taxonomy-{taxonomy}.php taxonomy.php archive.php index.php Modify Your texonomy Code snippet below : … Read more

Custom taxonomy terms hierarchical navigation

I managed to find a solution myself. This code is to be used in taxonomy templates. PHP: function show_taxonomy_navigation( $post_type=”post”, $taxonomy = ‘category’, $parent = 0 ) { $html = get_taxonomy_hierarchy( $post_type, $taxonomy, $parent ); echo $html; } function get_taxonomy_hierarchy( $post_type, $taxonomy, $parent = 0, $depth = 0 ) { $taxonomy = is_array( $taxonomy ) … Read more