Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?php //Do something if a specific array value exists within a post
  2.  
  3. $term_list = wp_get_post_terms($post->ID, 'serie', array("fields" => "all"));
  4.  
  5. $terms = get_terms( 'serie' );
  6.  
  7. foreach ( $terms as $term ) {
  8.  
  9. // The $term is an object, so we don't need to specify the $taxonomy.
  10. $term_link = get_term_link( $term );
  11.  
  12. // If there was an error, continue to the next term.
  13. if ( is_wp_error( $term_link ) ) {
  14. continue;
  15. }
  16.  
  17. // Then you can run a foreach loop to show the taxonomy terms infront.
  18. foreach ( $term_list as $term_single ) {
  19.  
  20. echo '<h2><a href="' . esc_url( $term_link ) . '">' . $term_single->name . '</a></h2>';
  21.  
  22. }
  23. }
  24.  
  25. ?>
  26.  
  27. $terms = get_terms( 'serie' );
  28.  
  29. $terms = get_the_terms( get_the_ID(), 'serie' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement