Guest User

Untitled

a guest
Apr 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. function tp_philosophy_pro_filter_get_team_options( $input ) {
  2. $options = tp_philosophy_pro_get_theme_options(); // get theme options
  3. $content_type = $options['team_options_content_type'];
  4. $content = array(); // create an empty array
  5.  
  6. switch ( $content_type ) {
  7. case 'category':
  8. $category_ids = ! empty( $options['team_options_content_category'] ) ? ( array ) $options['team_options_content_category'] : array();
  9.  
  10. // Bial if no category is selected
  11. if ( empty( $category_ids ) ) {
  12. return;
  13. }
  14.  
  15. $args = array(
  16. 'category__in' => $category_ids,
  17. 'posts_per_page' => 12,
  18. );
  19.  
  20. $team_posts = get_posts( $args );
  21.  
  22. $i = 1;
  23. foreach( $team_posts as $team_member ){
  24.  
  25. $member_id = $team_member->ID;
  26. $img_array = array();
  27.  
  28. if ( has_post_thumbnail( $member_id ) ) {
  29. $img_array = wp_get_attachment_image_src( get_post_thumbnail_id( $member_id ), 'tp-philosophy-pro-square-thumbnail' );
  30. } else {
  31. $img_array[0] = get_template_directory_uri().'/assets/uploads/no-featured-image-300x300.jpg';
  32. }
  33.  
  34. $content[$i]['member_id'] = $member_id;
  35. $content[$i]['img_array'] = $img_array;
  36. $content[$i]['url'] = get_permalink( $member_id );
  37. $content[$i]['title'] = get_the_title( $member_id );
  38. $content[$i]['description'] = '';
  39.  
  40.  
  41. $i++;
  42. }
  43. break;
  44.  
  45. case 'tp-philosophy-teams' :
  46. $team_category_ids = ! empty( $options['team_options_custom_taxonomy'] ) ? $options['team_options_custom_taxonomy'] : array();
  47.  
  48. // Bial if no category is selected
  49. if ( empty( $team_category_ids ) ) {
  50. return;
  51. }
  52.  
  53. $team_args = array(
  54. 'post_type' => 'tp-philosophy-teams',
  55. 'posts_per_page' => 20,
  56. 'tax_query' => array(
  57. array(
  58. 'taxonomy' => 'tp-philosophy-teams-category',
  59. 'field' => 'ID',
  60. 'terms' => $team_category_ids,
  61. )
  62. )
  63. );
  64.  
  65. $team_posts = get_posts( $team_args );
  66.  
  67. $i = 1;
  68. foreach( $team_posts as $team_member ){
  69.  
  70. $member_id = $team_member->ID;
  71. $img_array = array();
  72.  
  73. if ( has_post_thumbnail( $member_id ) ) {
  74. $img_array = wp_get_attachment_image_src( get_post_thumbnail_id( $member_id ), 'tp-philosophy-pro-square-thumbnail' );
  75. } else {
  76. $img_array[0] = get_template_directory_uri().'/assets/uploads/no-featured-image-300x300.jpg';
  77. }
  78.  
  79. $content[$i]['img_array'] = $img_array;
  80. $content[$i]['member_id'] = $member_id;
  81. $content[$i]['url'] = get_permalink( $member_id );
  82. $content[$i]['title'] = get_the_title( $member_id );
  83. $content[$i]['description'] = $team_member->post_content;
  84.  
  85. $i++;
  86. }
  87. break;
  88.  
  89. default :
  90. break;
  91. }
  92.  
  93. if( ! empty( $content ) ) {
  94. $input = $content;
  95. }
  96.  
  97. return $input;
  98. }
Add Comment
Please, Sign In to add comment