Guest User

Untitled

a guest
Nov 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. function woo_post_meta( $section = '' ) {
  2.  
  3. global $post;
  4.  
  5. if ( ! defined( 'WOO_DATE_FORMAT' ) ) {
  6. define( 'WOO_DATE_FORMAT', get_option( 'date_format' ) );
  7. }
  8.  
  9. $categories_obj = get_the_category( $post->ID );
  10. $prepared_categories = array();
  11. $the_category = '';
  12.  
  13. if ( count( $categories_obj ) && ! is_wp_error( $categories_obj ) ) {
  14. foreach ( $categories_obj as $c ) {
  15. $prepared_categories[] = '<a href="' . get_term_link( $c->slug, 'category' ) . '">' . $c->name . '</a>';
  16. }
  17.  
  18. if ( $section == 'more-news' ) {
  19. $the_category = $prepared_categories[0];
  20. } else {
  21. $the_category = join( ', ', $prepared_categories );
  22. }
  23. }
  24. ?>
  25. <div class="post-meta">
  26. <span class="category"><?php echo $the_category; ?></span>
  27. <span class="date"><?php echo the_time( WOO_DATE_FORMAT ); ?></span>
  28. <div class="fix"></div>
  29. </div>
  30. <?php
  31. }
Add Comment
Please, Sign In to add comment