Guest User

Untitled

a guest
Jan 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. taxonomy-{taxonomy}-{term}.php
  2.  
  3. taxonomy-maintenance-professional.php
  4.  
  5. $args = array(
  6. 'orderby' => 'name',
  7. 'order' => 'ASC',
  8. 'hide_empty' => TRUE,
  9. 'fields' => 'all',
  10. );
  11. $terms = get_terms( 'project_type', $args);
  12.  
  13. if (
  14. ! is_wp_error( $terms )
  15. && ! empty( $terms )
  16. ) {
  17. echo '<ul>';
  18.  
  19. foreach ( $terms as $term ) {
  20. $url = get_term_link( $term );
  21. if ( is_wp_error( $url ) ) {
  22. continue;
  23. }
  24.  
  25. $url = add_query_arg( 'post_type', 'projects', $url );
  26. printf(
  27. '<li><a href="%s">%s</a></li>',
  28. $url,
  29. $term->name
  30. );
  31. }
  32.  
  33. echo '</ul>';
  34. }
  35.  
  36. $post_type = get_post_type();
  37.  
  38. if ( is_post_type_archive() ) {
  39. $taxonomies = get_object_taxonomies($post_type);
  40. $related_terms = get_terms(array(
  41. 'taxonomy' => $taxonomies
  42. ));
  43. }
  44.  
  45. if ( !empty($related_terms) && !is_wp_error($related_terms) ) {
  46. foreach ( $related_terms as $related_term ) {
  47. $term_url = get_term_link($related_term);
  48.  
  49. if ( is_post_type_archive() ) {
  50. $term_url = add_query_arg( 'post_type', $post_type, $term_url );
  51. }
  52. ?>
  53. <a href="<?php echo esc_url($term_url); ?>"><?php echo $related_term->name; ?></a>
  54. <?php }
  55. }
Add Comment
Please, Sign In to add comment