Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. function arg_results2( $atts, $content ) {
  2. $atts = shortcode_atts(
  3. array(
  4. 'total_results' => '',
  5. ), $atts
  6. );
  7.  
  8. global $post;
  9.  
  10. $output = array();
  11.  
  12.  
  13.  
  14. $query_args = array(
  15. 'posts_per_page' => $atts['total_results'],
  16. 'orderby' => 'publish_date',
  17. 'order' => 'DESC',
  18. 'post_type' => 'argpredictions',
  19. 'no_found_rows' => true,
  20.  
  21. );
  22. $prefix = '';
  23. $arg_teams = rwmb_meta( 'ap-post-meta' );
  24.  
  25. $query = new WP_Query( $query_args );
  26. if ( $query->have_posts() ){
  27. while ( $query->have_posts() ) : $query->the_post();
  28.  
  29. $terms = wp_get_object_terms( $post->ID, 'league' );
  30.  
  31. foreach ( $terms as $term ) {
  32. $league_title = $term->name;
  33. }
  34.  
  35. //var_dump( $terms );
  36.  
  37. $home_team_id = get_post_meta( get_the_ID(),'home_team',true );
  38. $home_team = get_the_title($home_team_id);
  39. $home_team_img_url = get_the_post_thumbnail_url($home_team_id,'full');
  40.  
  41. // Away team meta
  42. $away_team_id = get_post_meta( get_the_ID(),'away_team',true );
  43. $away_team = get_the_title($away_team_id);
  44. $away_team_img_url = get_the_post_thumbnail_url($away_team_id,'full');
  45.  
  46. $fixture_date = get_post_meta( get_the_ID(),'prediction_date',true );
  47. $fixture_time = get_post_meta( get_the_ID(),'prediction_time',true );
  48. $match_coef = get_post_meta( get_the_ID(),'prediction_coef',true );
  49.  
  50. $link = get_the_permalink();
  51. $link_title = get_the_title();
  52. $thumbnail = get_the_post_thumbnail();
  53.  
  54.  
  55. if ( ! is_single() ) :
  56. $output[] .='<article class="argument-predictions">';
  57. $output[] .='<div class="entry-title"><a href="'.$link.'" title="'.$link_title.'"><div>'.$league_title.'</div></a></div>';
  58. $output[] .='<div class="row argument-predictions-container">';
  59. if ( '' !== get_the_post_thumbnail() && ! is_single() ) :
  60. $output[] .='<div class="col-md-3 post-thumbnail">'.$thumbnail.'</div>';
  61. $output[] .='<div class="col-md-9 argument-prediction-content">';
  62. $output[] .='<div class="col-md-4 team">';
  63. $output[] .='<div class="team-logo"><img src="'.$home_team_img_url.'" width="auto" height="auto"></div>';
  64. $output[] .='<div class="team-name">'.$home_team.'</div></div>';
  65. $output[] .='<div class="col-md-4 match-info">';
  66. $output[] .='<div class="starting-date"><span>'.esc_html__('Коеф', 'betinum').' - '.$match_coef.'</span></div>';
  67. $output[] .='<div class="starting-time">'.$fixture_time.'</div>';
  68. $output[] .='<div class="arg-prediction button"><a href="'.$link.'" title="'.$link_title.'">'.esc_html__('Към прогнозата', 'betinum').'</a></div></div>';
  69. $output[] .='<div class="col-md-4 team">';
  70. $output[] .='<div class="team-logo"><img src="'.$away_team_img_url.'" width="auto" height="auto"></div>';
  71. $output[] .='<div class="team-name">'.$away_team.'</div></div></div></div>';
  72. endif;
  73. $output[] .='</article>';
  74. endif;
  75.  
  76. endwhile;
  77. wp_reset_postdata();
  78. }
  79.  
  80. return sprintf(
  81. '<div class="arg-predictions-wrapper">
  82. %s
  83. </div>',
  84. implode( '', $output )
  85. );
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement