Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tp_philosophy_pro_filter_get_team_options( $input ) {
- $options = tp_philosophy_pro_get_theme_options(); // get theme options
- $content_type = $options['team_options_content_type'];
- $content = array(); // create an empty array
- switch ( $content_type ) {
- case 'category':
- $category_ids = ! empty( $options['team_options_content_category'] ) ? ( array ) $options['team_options_content_category'] : array();
- // Bial if no category is selected
- if ( empty( $category_ids ) ) {
- return;
- }
- $args = array(
- 'category__in' => $category_ids,
- 'posts_per_page' => 12,
- );
- $team_posts = get_posts( $args );
- $i = 1;
- foreach( $team_posts as $team_member ){
- $member_id = $team_member->ID;
- $img_array = array();
- if ( has_post_thumbnail( $member_id ) ) {
- $img_array = wp_get_attachment_image_src( get_post_thumbnail_id( $member_id ), 'tp-philosophy-pro-square-thumbnail' );
- } else {
- $img_array[0] = get_template_directory_uri().'/assets/uploads/no-featured-image-300x300.jpg';
- }
- $content[$i]['member_id'] = $member_id;
- $content[$i]['img_array'] = $img_array;
- $content[$i]['url'] = get_permalink( $member_id );
- $content[$i]['title'] = get_the_title( $member_id );
- $content[$i]['description'] = '';
- $i++;
- }
- break;
- case 'tp-philosophy-teams' :
- $team_category_ids = ! empty( $options['team_options_custom_taxonomy'] ) ? $options['team_options_custom_taxonomy'] : array();
- // Bial if no category is selected
- if ( empty( $team_category_ids ) ) {
- return;
- }
- $team_args = array(
- 'post_type' => 'tp-philosophy-teams',
- 'posts_per_page' => 20,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'tp-philosophy-teams-category',
- 'field' => 'ID',
- 'terms' => $team_category_ids,
- )
- )
- );
- $team_posts = get_posts( $team_args );
- $i = 1;
- foreach( $team_posts as $team_member ){
- $member_id = $team_member->ID;
- $img_array = array();
- if ( has_post_thumbnail( $member_id ) ) {
- $img_array = wp_get_attachment_image_src( get_post_thumbnail_id( $member_id ), 'tp-philosophy-pro-square-thumbnail' );
- } else {
- $img_array[0] = get_template_directory_uri().'/assets/uploads/no-featured-image-300x300.jpg';
- }
- $content[$i]['img_array'] = $img_array;
- $content[$i]['member_id'] = $member_id;
- $content[$i]['url'] = get_permalink( $member_id );
- $content[$i]['title'] = get_the_title( $member_id );
- $content[$i]['description'] = $team_member->post_content;
- $i++;
- }
- break;
- default :
- break;
- }
- if( ! empty( $content ) ) {
- $input = $content;
- }
- return $input;
- }
Add Comment
Please, Sign In to add comment