Advertisement
Guest User

Untitled

a guest
May 24th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  2. <header class="entry-header">
  3. <?php the_title( sprintf( '<h1 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' ); ?>
  4. </header>
  5. <?php
  6. echo '<div class="entry-summary">';
  7.  
  8. function my_generate_excerpt( $content ) {
  9. $max_words = 150;
  10. $after = '[...]';
  11.  
  12. // remove HTML
  13. $excerpt = strip_tags( $content );
  14.  
  15. // truncate to $max_words and append ellipsis
  16. $excerpt = explode( ' ', $excerpt );
  17. if ( count( $excerpt ) > $max_words ) {
  18. $excerpt = array_slice( $excerpt, 0, $max_words );
  19. $excerpt .= $after;
  20. }
  21.  
  22. return $excerpt;
  23. }
  24.  
  25. // output applicable ACF-facilitated 'excerpt' based on post type
  26. switch ( get_post_type() ) {
  27.  
  28. // post-type: single-expertise
  29. case 'expertise':
  30. echo '<p class="expertise">' . my_generate_excerpt( the_field( 'expertise_description' ) ). '</p>';
  31. break;
  32.  
  33. // post-type: single-team-members
  34. case 'team-members':
  35. echo '<p class="team-member">' . my_generate_excerpt( the_field( 'member_bio' ) ). '</p>';
  36. break;
  37.  
  38. // post-type: single-projects
  39. case 'project':
  40. echo '<p class="project">' . my_generate_excerpt( the_field( 'project_description' ) ). '</p>';
  41. break;
  42.  
  43. // post-type: "default" (news-articles, resources)
  44. default:
  45. // fall back to any excerpt
  46. if( function_exists( 'searchwp_term_highlight_the_excerpt_global' ) ) {
  47. searchwp_term_highlight_the_excerpt_global();
  48. } else {
  49. the_excerpt();
  50. }
  51. break;
  52. }
  53. echo '</div>';
  54. ?>
  55. </article>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement