Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- remove_action( 'genesis_post_content', 'custom_excerpt' );
- add_action( 'genesis_post_content', 'custom_excerpt' );
- function custom_excerpt() {
- // Return if CPT Hotels
- if ( is_post_type_archive( 'hotels' ) )
- // Store the address data
- $address_data = array(
- 'address_1' => get_field( 'Address_1' ),
- 'address_2' => get_field( 'street_address_2' ),
- 'po_box' => get_field( 'po_box' ),
- 'city' => get_field( 'city' ),
- 'state' => get_field( 'state' ),
- 'zip' => get_field( 'zip' ),
- );
- // Only output if we have location data
- if( $address_data ) {
- echo '<div class="details">Details</div>';
- echo '<div class="location-wrap one-half first">';
- if ( $address_data['address_1'] ) {
- echo '<div class="location">' . esc_attr( $address_data['address_1'] ) . '</div>';
- }
- if ( $address_data['address_2'] ) {
- echo '<div class="location">' . esc_attr( $address_data['address_2'] ) . '</div>';
- }
- if ( $address_data['po_box'] ) {
- echo '<div class="location">' . esc_attr( $address_data['po_box'] ) . '</div>';
- }
- if ( $address_data['city'] ) {
- echo '<span>' . esc_attr( $address_data['city'] ) . '</span>';
- }
- if ( $address_data['state'] ) {
- echo '<span>, ' . esc_attr( $address_data['state'] ) . '</span>';
- }
- if ( $address_data['zip'] ) {
- echo '<span> ' . esc_attr( $address_data['zip'] ) . '</span>';
- }
- echo '</div>';
- }
- if ( '' != $address_data ) {
- $address_data = strip_shortcodes( $text );
- $address_data = apply_filters('the_content', $text);
- $allowed_tags = '<p>,<a>,<em>,<strong>,<img>';
- $address_data = strip_tags($text, $allowed_tags);
- $address_data = str_replace(']]>', ']]>', $text);
- $excerpt_length = 40; // 20 words
- $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
- $address_data = wp_trim_words( $text, $excerpt_length, $excerpt_more );
- }
- return apply_filters('the_excerpt', $text);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement