Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. // Categories
  2. $start = microtime(true);
  3. $cats = get_the_category();
  4. if ( $cats ) {
  5. foreach ( $cats as $cat ) {
  6. $cat_list[] = '<a href="' . get_category_link( $cat->term_id ) . '">' . $cat->cat_name . '</a>';
  7. }
  8. }
  9. /**
  10. * Filters the list of category links to be displyaed on Post's entry meta
  11. *
  12. * @see tujtheme_post_entry_meta()
  13. *
  14. * @param string $array Category links.
  15. */
  16. $cat_list = apply_filters( 'tujtheme_filter_post_entry_meta_cat', $cat_list );
  17. $cat_list = implode( ', ', $cat_list );
  18. $cat_list = rtrim( $cat_list, ',' );
  19. echo microtime(true) - $start, PHP_EOL;
  20.  
  21. 0.0013430118560791
  22.  
  23.  
  24. // Categories
  25. $start = microtime(true);
  26. $cats = get_the_category();
  27. if ( $cats ) {
  28. $i = 1;
  29. $sep = ', ';
  30. foreach ( $cats as $cat ) {
  31. if ( $i === count( $cats ) ) {
  32. $sep = '';
  33. }
  34. $cat_list[] = '<a href="' . get_category_link( $cat->term_id ) . '">' . $cat->cat_name . '</a>' . $sep;
  35. $i++;
  36. }
  37. }
  38. /**
  39. * Filters the list of category links to be displyaed on Post's entry meta
  40. *
  41. * @see tujtheme_post_entry_meta()
  42. *
  43. * @param string $array Category links.
  44. */
  45. $cat_list = apply_filters( 'tujtheme_filter_post_entry_meta_cat', $cat_list );
  46. $cat_list = implode( '', $cat_list );
  47. echo microtime(true) - $start, PHP_EOL;
  48.  
  49. 0.00087213516235352
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement