Last active
          March 31, 2017 17:53 
        
      - 
      
- 
        Save apsolut/e76abd5c0ec3b98af203a8e72cc19df4 to your computer and use it in GitHub Desktop. 
    ACF slider for Pages & Categories
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <div class="mls-slider-wrapper no-print"> | |
| <?php | |
| global $wp_query; | |
| $term_id = null; | |
| $taxonomy = null; | |
| $queried_object = get_queried_object(); | |
| if ( ( ! $queried_object == null ) && ! is_search() && ! is_404() ) { | |
| $taxonomy = $queried_object->taxonomy; | |
| $term_id = $queried_object->term_id; | |
| } | |
| if ( get_field( 'enable_slider_category', $taxonomy . '_' . $term_id ) ) : | |
| ?> | |
| <div id="mls-slider" class="mls-slider"> | |
| <?php if ( have_rows( 'images_flexible_category', $taxonomy . '_' . $term_id ) ): ?> | |
| <?php while ( have_rows( 'images_flexible_category', $taxonomy . '_' . $term_id ) ) : the_row(); ?> | |
| <?php if ( get_row_layout() == 'slider_layout' ): ?> | |
| <div class="ms-inside"> | |
| <div class="ms-image"> | |
| <?php | |
| $slider_img = get_sub_field( 'image_slider', $taxonomy . '_' . $term_id ); | |
| if ( ! empty( $slider_img ) ): | |
| $url = $slider_img['url']; | |
| $size = 'small-slider-image'; | |
| $slideimg = $slider_img['sizes'][ $size ]; | |
| ?> | |
| <img src="<?php echo $slideimg; ?>"> | |
| <?php endif; ?> | |
| </div> | |
| <?php if ( get_sub_field( 'text_slider_heading', $taxonomy . '_' . $term_id ) ) : ?> | |
| <div class="ms-text"> | |
| <div class="dg__container"> | |
| <?php if ( get_sub_field( 'text_slider_heading', $taxonomy . '_' . $term_id ) ) : ?> | |
| <div class="slider-text"> | |
| <div class="heading"> | |
| <?php the_sub_field( 'text_slider_heading', $taxonomy . '_' . $term_id ); ?> | |
| </div> | |
| <div class="description"><?php the_sub_field( 'text_slider_description', $taxonomy . '_' . $term_id ); ?></div> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| </div> | |
| <?php else: ?> | |
| <?php endif; ?> | |
| </div> | |
| <?php endif; endwhile; ?> | |
| <?php endif; ?> | |
| </div> | |
| <?php elseif ( get_field( 'enable_slider' ) && ( is_page() || is_category() || is_single() || is_singular() || is_post_type_archive() ) ) : ?> | |
| <div id="mls-slider" class="mls-slider"> | |
| <?php if ( have_rows( 'images_flexible' ) ): ?> | |
| <?php while ( have_rows( 'images_flexible' ) ) : the_row(); ?> | |
| <?php if ( get_row_layout() == 'slider_layout' ): ?> | |
| <div class="ms-inside"> | |
| <div class="ms-image"> | |
| <?php | |
| $slider_img = get_sub_field( 'image_slider' ); | |
| if ( ! empty( $slider_img ) ): | |
| $url = $slider_img['url']; | |
| if ( is_front_page() ) { | |
| $size = 'custom-slider-image'; | |
| } else { | |
| $size = 'custom-slider-image'; | |
| } | |
| $slideimg = $slider_img['sizes'][ $size ]; | |
| ?> | |
| <img src="<?php echo $slideimg; ?>" | |
| alt="<?php the_sub_field( 'text_slider_heading' ); ?>"> | |
| <?php endif; ?> | |
| </div> | |
| <div class="ms-text"> | |
| <div class="dg__container"> | |
| <?php if ( get_sub_field( 'text_slider_heading' ) ) : ?> | |
| <div class="slider-text"> | |
| <div class="heading"> | |
| <?php the_sub_field( 'text_slider_heading' ); ?> | |
| </div> | |
| <div class="description"><?php the_sub_field( 'text_slider_description' ); ?></div> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| <div class="ms-buttons"> | |
| <button class="btn-default"> | |
| <i class="fa fa-compass" aria-hidden="true"></i> Mehr zur location | |
| </button> | |
| <button class="btn-default"> | |
| <i class="fa fa-compass" aria-hidden="true"></i> Virtueller Rundgang | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <?php endif; endwhile; ?> | |
| <?php endif; ?> | |
| </div> | |
| <?php else: ?> | |
| <div id="mls-slider-static" class="mls-slider-static"> | |
| <?php | |
| $backup_slider_img = get_field( 'default_background_image', 'option' ); | |
| if ( ! empty( $backup_slider_img ) ): | |
| $url = $backup_slider_img['url']; | |
| if ( is_front_page() ) { | |
| $size = 'custom-slider-image'; | |
| } else { | |
| $size = 'small-slider-image'; | |
| } | |
| $bslideimg = $backup_slider_img['sizes'][ $size ]; | |
| ?> | |
| <img src="<?php echo $bslideimg; ?>"> | |
| <?php endif; ?> | |
| </div> | |
| <?php endif; ?> | |
| <?php if ( is_front_page() || is_page() ) : ?> | |
| <div id="godown" class="godown box-shadow" data-class=""> | |
| <a href="#godown" id="btn-float" class="btn-float"> | |
| <i class="fa fa-angle-down" aria-hidden="true"></i> | |
| </a> | |
| </div> | |
| <?php endif; ?> | |
| </div> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| if( function_exists('acf_add_local_field_group') ): | |
| acf_add_local_field_group(array ( | |
| 'key' => 'group_58a1e40bacc2e', | |
| 'title' => 'Category - Slider', | |
| 'fields' => array ( | |
| array ( | |
| 'key' => 'field_58a1e40bb0e72', | |
| 'label' => 'Enable slider', | |
| 'name' => 'enable_slider_category', | |
| 'type' => 'true_false', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'message' => '', | |
| 'default_value' => 0, | |
| 'ui' => 1, | |
| 'ui_on_text' => 'Enabled', | |
| 'ui_off_text' => 'Disabled', | |
| ), | |
| array ( | |
| 'key' => 'field_58a1e40bb0f37', | |
| 'label' => 'Images', | |
| 'name' => 'images_flexible_category', | |
| 'type' => 'flexible_content', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'button_label' => 'Add Slider', | |
| 'min' => '', | |
| 'max' => '', | |
| 'layouts' => array ( | |
| array ( | |
| 'key' => '5849a33a9b790', | |
| 'name' => 'slider_layout', | |
| 'label' => 'Slider', | |
| 'display' => 'block', | |
| 'sub_fields' => array ( | |
| array ( | |
| 'key' => 'field_58a1e40bb8c71', | |
| 'label' => 'Image', | |
| 'name' => 'image_slider', | |
| 'type' => 'image', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '100', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'return_format' => 'array', | |
| 'preview_size' => 'custom-category-image', | |
| 'library' => 'all', | |
| 'min_width' => '', | |
| 'min_height' => '', | |
| 'min_size' => '', | |
| 'max_width' => '', | |
| 'max_height' => '', | |
| 'max_size' => '', | |
| 'mime_types' => '', | |
| ), | |
| array ( | |
| 'key' => 'field_58de1dd85e329', | |
| 'label' => 'Heading', | |
| 'name' => 'text_slider_heading', | |
| 'type' => 'text', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'default_value' => '', | |
| 'placeholder' => '', | |
| 'prepend' => '', | |
| 'append' => '', | |
| 'maxlength' => '', | |
| ), | |
| array ( | |
| 'key' => 'field_58de1de25e32a', | |
| 'label' => 'Description', | |
| 'name' => 'text_slider_description', | |
| 'type' => 'textarea', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'default_value' => '', | |
| 'placeholder' => '', | |
| 'maxlength' => '', | |
| 'rows' => 4, | |
| 'new_lines' => 'wpautop', | |
| ), | |
| ), | |
| 'min' => '', | |
| 'max' => '', | |
| ), | |
| ), | |
| ), | |
| ), | |
| 'location' => array ( | |
| array ( | |
| array ( | |
| 'param' => 'taxonomy', | |
| 'operator' => '==', | |
| 'value' => 'category', | |
| ), | |
| ), | |
| ), | |
| 'menu_order' => 0, | |
| 'position' => 'acf_after_title', | |
| 'style' => 'default', | |
| 'label_placement' => 'top', | |
| 'instruction_placement' => 'label', | |
| 'hide_on_screen' => '', | |
| 'active' => 1, | |
| 'description' => '', | |
| )); | |
| acf_add_local_field_group(array ( | |
| 'key' => 'group_5849a0dddd2d6', | |
| 'title' => 'Global - Settings', | |
| 'fields' => array ( | |
| array ( | |
| 'key' => 'field_588f290f0dc86', | |
| 'label' => 'Content', | |
| 'name' => '', | |
| 'type' => 'tab', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'placement' => 'left', | |
| 'endpoint' => 0, | |
| ), | |
| array ( | |
| 'key' => 'field_588f291d0dc87', | |
| 'label' => 'Content', | |
| 'name' => '', | |
| 'type' => 'message', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'message' => '', | |
| 'esc_html' => 0, | |
| 'new_lines' => 'wpautop', | |
| ), | |
| array ( | |
| 'key' => 'field_588f29040dc85', | |
| 'label' => 'Slider', | |
| 'name' => '', | |
| 'type' => 'tab', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'placement' => 'left', | |
| 'endpoint' => 0, | |
| ), | |
| array ( | |
| 'key' => 'field_5849a58a17f14', | |
| 'label' => 'Enable slider', | |
| 'name' => 'enable_slider', | |
| 'type' => 'true_false', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'default_value' => 0, | |
| 'message' => '', | |
| 'ui' => 1, | |
| 'ui_on_text' => 'Enabled', | |
| 'ui_off_text' => 'Disabled', | |
| ), | |
| array ( | |
| 'key' => 'field_5849a1d268988', | |
| 'label' => 'Images', | |
| 'name' => 'images_flexible', | |
| 'type' => 'flexible_content', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'button_label' => 'Add Slider', | |
| 'min' => '', | |
| 'max' => '', | |
| 'layouts' => array ( | |
| array ( | |
| 'key' => '5849a33a9b790', | |
| 'name' => 'slider_layout', | |
| 'label' => 'Slider', | |
| 'display' => 'block', | |
| 'sub_fields' => array ( | |
| array ( | |
| 'key' => 'field_5849a290ff928', | |
| 'label' => 'Image', | |
| 'name' => 'image_slider', | |
| 'type' => 'image', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'return_format' => 'array', | |
| 'preview_size' => 'thumbnail', | |
| 'library' => 'all', | |
| 'min_width' => '', | |
| 'min_height' => '', | |
| 'min_size' => '', | |
| 'max_width' => '', | |
| 'max_height' => '', | |
| 'max_size' => '', | |
| 'mime_types' => '', | |
| ), | |
| array ( | |
| 'key' => 'field_5849a236f0dfa', | |
| 'label' => 'Heading', | |
| 'name' => 'text_slider_heading', | |
| 'type' => 'text', | |
| 'instructions' => 'If you dont put heading text nothing will show...', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'default_value' => '', | |
| 'placeholder' => '', | |
| 'prepend' => '', | |
| 'append' => '', | |
| 'maxlength' => '', | |
| ), | |
| array ( | |
| 'key' => 'field_589df1e976093', | |
| 'label' => 'Description', | |
| 'name' => 'text_slider_description', | |
| 'type' => 'textarea', | |
| 'instructions' => '', | |
| 'required' => 0, | |
| 'conditional_logic' => 0, | |
| 'wrapper' => array ( | |
| 'width' => '', | |
| 'class' => '', | |
| 'id' => '', | |
| ), | |
| 'default_value' => '', | |
| 'placeholder' => '', | |
| 'maxlength' => '', | |
| 'rows' => 2, | |
| 'new_lines' => 'wpautop', | |
| ), | |
| ), | |
| 'min' => '', | |
| 'max' => '', | |
| ), | |
| ), | |
| ), | |
| ), | |
| 'location' => array ( | |
| array ( | |
| array ( | |
| 'param' => 'post_type', | |
| 'operator' => '==', | |
| 'value' => 'page', | |
| ), | |
| ), | |
| array ( | |
| array ( | |
| 'param' => 'post_type', | |
| 'operator' => '==', | |
| 'value' => 'post', | |
| ), | |
| ), | |
| array ( | |
| array ( | |
| 'param' => 'post_type', | |
| 'operator' => '==', | |
| 'value' => 'post', | |
| ), | |
| ), | |
| ), | |
| 'menu_order' => 0, | |
| 'position' => 'acf_after_title', | |
| 'style' => 'default', | |
| 'label_placement' => 'top', | |
| 'instruction_placement' => 'label', | |
| 'hide_on_screen' => '', | |
| 'active' => 1, | |
| 'description' => '', | |
| )); | |
| endif; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment