Advertisement
AMEEKER

Untitled

Aug 23rd, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. remove_action( 'genesis_post_content', 'custom_excerpt' );
  2. add_action( 'genesis_post_content', 'custom_excerpt' );
  3. function custom_excerpt() {
  4.     // Return if CPT Hotels
  5.     if ( is_post_type_archive( 'hotels' ) )
  6.     // Store the address data
  7.     $address_data = array(
  8.         'address_1' => get_field( 'Address_1' ),
  9.         'address_2' => get_field( 'street_address_2' ),
  10.         'po_box'    => get_field( 'po_box' ),
  11.         'city'      => get_field( 'city' ),
  12.         'state'     => get_field( 'state' ),
  13.         'zip'       => get_field( 'zip' ),
  14.     );
  15.    
  16.     // Only output if we have location data
  17.     if( $address_data ) {
  18.     echo '<div class="details">Details</div>';
  19.         echo '<div class="location-wrap one-half first">';
  20.             if ( $address_data['address_1'] ) {
  21.                 echo '<div class="location">' . esc_attr( $address_data['address_1'] ) . '</div>';
  22.             }
  23.             if ( $address_data['address_2'] ) {
  24.                 echo '<div class="location">' . esc_attr( $address_data['address_2'] ) . '</div>';
  25.             }
  26.             if ( $address_data['po_box'] ) {
  27.                 echo '<div class="location">' . esc_attr( $address_data['po_box'] ) . '</div>';
  28.             }
  29.             if ( $address_data['city'] ) {
  30.                 echo '<span>' . esc_attr( $address_data['city'] ) . '</span>';
  31.             }
  32.             if ( $address_data['state'] ) {
  33.                 echo '<span>, ' . esc_attr( $address_data['state'] ) . '</span>';
  34.             }
  35.             if ( $address_data['zip'] ) {
  36.                 echo '<span> ' . esc_attr( $address_data['zip'] ) . '</span>';
  37.             }
  38.         echo '</div>';
  39.     }
  40. if ( '' != $address_data ) {
  41.         $address_data = strip_shortcodes( $text );
  42.         $address_data = apply_filters('the_content', $text);
  43.         $allowed_tags = '<p>,<a>,<em>,<strong>,<img>';
  44.         $address_data = strip_tags($text, $allowed_tags);
  45.         $address_data = str_replace(']]>', ']]>', $text);
  46.         $excerpt_length = 40; // 20 words
  47.         $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
  48.         $address_data = wp_trim_words( $text, $excerpt_length, $excerpt_more );
  49.     }
  50.     return apply_filters('the_excerpt', $text);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement