Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Hotel Excerpts
- *
- * Display an excerpt of address
- * on Hotel CPTS using ACF.
- *
- * @author Angie Meeker
- * @uses Advanced Custom Fields
- */
- remove_action( 'genesis_post_content', 'hotel_excerpt' );
- add_action( 'genesis_post_content', 'hotel_excerpt' );
- function hotel_excerpt() {
- // Return if CPT Hotels
- if ( is_post_type_archive( 'hotels' ) )
- // Store the address data
- $hotel_excerpt_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' ),
- 'phone' => get_field( 'phone' ),
- 'website' => get_field( 'website' ),
- );
- // Only output if we have location data
- if( $hotel_excerpt_data ) {
- echo '<div class="hotelexcerpt">';
- if ( $hotel_excerpt_data['address_1'] ) {
- echo '<div class="location">' . esc_attr( $hotel_excerpt_data['address_1'] ) . '</div>';
- }
- if ( $hotel_excerpt_data['address_2'] ) {
- echo '<div class="location">' . esc_attr( $hotel_excerpt_data['address_2'] ) . '</div>';
- }
- if ( $hotel_excerpt_data['po_box'] ) {
- echo '<div class="location">' . esc_attr( $hotel_excerpt_data['po_box'] ) . '</div>';
- }
- if ( $hotel_excerpt_data['city'] ) {
- echo '<span>' . esc_attr( $hotel_excerpt_data['city'] ) . '</span>';
- }
- if ( $hotel_excerpt_data['state'] ) {
- echo '<span>, ' . esc_attr( $hotel_excerpt_data['state'] ) . '</span>';
- }
- if ( $hotel_excerpt_data['zip'] ) {
- echo '<span> ' . esc_attr( $hotel_excerpt_data['zip'] ) . '</span>';
- }
- if ( $hotel_excerpt_data['phone'] ) {
- echo '<div class="location">' . esc_attr( $hotel_excerpt_data['phone'] ) . '</div>';
- }
- if ( $hotel_excerpt_data['website'] ) {
- echo '<div class="location"><a href="' . esc_url( $hotel_excerpt_data['website'] ) . '">Visit Our Website</a></div>';
- }
- if ( $hotel_excerpt_data['email'] ) {
- echo '<div class="location"><a href="mailto:' . esc_attr( $hotel_excerpt_data['email'] ) . '">Email</a></div>';
- }
- echo '</div>';
- }
- if ( '' != $hotel_excerpt_data ) {
- $hotel_excerpt_data = strip_shortcodes( $text );
- $hotel_excerpt_data = apply_filters('the_content', $text);
- $allowed_tags = '<p>,<a>,<em>,<strong>,<img>';
- $hotel_excerpt_data = strip_tags($text, $allowed_tags);
- $hotel_excerpt_data = str_replace(']]>', ']]>', $text);
- $excerpt_length = 0; // 20 words
- $hotel_excerpt_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