Created
May 11, 2017 05:41
-
-
Save anonymous/f418d196646b5b800210e808a7b87687 to your computer and use it in GitHub Desktop.
This file contains 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
add_post_type_support( 'page', 'excerpt' ); | |
function charitize_featured_slider_array( $from_slider ){ | |
global $charitize_customizer_all_values; | |
$charitize_feature_slider_number = absint( $charitize_customizer_all_values['charitize-feature-slider-number'] ); | |
$charitize_feature_slider_single_words = absint( $charitize_customizer_all_values['charitize-fs-single-words'] ); | |
$charitize_feature_slider_contents_array[0]['charitize-feature-slider-title'] = __('Welcome to charitize','charitize'); | |
$charitize_feature_slider_contents_array[0]['charitize-feature-slider-content'] = __('Unlike other companies, we do not charge hundreds of dollars per theme.','charitize'); | |
$charitize_feature_slider_contents_array[0]['charitize-feature-slider-link'] = '#'; | |
$charitize_feature_slider_contents_array[0]['charitize-feature-slider-image'] = get_template_directory_uri()."/assets/img/slider.png"; | |
$repeated_page = array('charitize-feature-slider-pages-ids'); | |
$charitize_feature_slider_args = array(); | |
if ( 'from-category' == $from_slider ){ | |
$charitize_feature_slider_category = $charitize_customizer_all_values['charitize-featured-slider-category']; | |
if( 0 != $charitize_feature_slider_category ){ | |
$charitize_feature_slider_args = array( | |
'post_type' => 'post', | |
'cat' => $charitize_feature_slider_category, | |
'ignore_sticky_posts' => true | |
); | |
} | |
} | |
else{ | |
$charitize_feature_slider_posts = evision_customizer_get_repeated_all_value(6 , $repeated_page); | |
$charitize_feature_slider_posts_ids = array(); | |
if( null != $charitize_feature_slider_posts ) { | |
foreach( $charitize_feature_slider_posts as $charitize_feature_slider_post ) { | |
if( 0 != $charitize_feature_slider_post['charitize-feature-slider-pages-ids'] ){ | |
$charitize_feature_section_posts_ids[] = $charitize_feature_slider_post['charitize-feature-slider-pages-ids']; | |
} | |
} | |
if( !empty( $charitize_feature_section_posts_ids )){ | |
$charitize_feature_slider_args = array( | |
'post_type' => 'page', | |
'post__in' => $charitize_feature_section_posts_ids, | |
'posts_per_page' => $charitize_feature_slider_number, | |
'orderby' => 'post__in' | |
); | |
} | |
} | |
} | |
if( !empty( $charitize_feature_slider_args )){ | |
// the query | |
$charitize_fature_section_post_query = new WP_Query( $charitize_feature_slider_args ); | |
if ( $charitize_fature_section_post_query->have_posts() ) : | |
$i = 0; | |
while ( $charitize_fature_section_post_query->have_posts() ) : $charitize_fature_section_post_query->the_post(); | |
$url =''; | |
if(has_post_thumbnail()){ | |
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'charitize-home-main-slider' ); | |
$url = $thumb['0']; | |
} | |
$charitize_feature_slider_contents_array[$i]['charitize-feature-slider-title'] = get_the_title(); | |
$charitize_feature_slider_contents_array[$i]['charitize-feature-slider-content'] = charitize_words_count( $charitize_feature_slider_single_words ,get_the_excerpt());; | |
$charitize_feature_slider_contents_array[$i]['charitize-feature-slider-link'] = get_permalink(); | |
$charitize_feature_slider_contents_array[$i]['charitize-feature-slider-image'] = $url; | |
$i++; | |
endwhile; | |
wp_reset_postdata(); | |
endif; | |
} | |
return $charitize_feature_slider_contents_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment