Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function arg_results2( $atts, $content ) {
- $atts = shortcode_atts(
- array(
- 'total_results' => '',
- ), $atts
- );
- global $post;
- $output = array();
- $query_args = array(
- 'posts_per_page' => $atts['total_results'],
- 'orderby' => 'publish_date',
- 'order' => 'DESC',
- 'post_type' => 'argpredictions',
- 'no_found_rows' => true,
- );
- $prefix = '';
- $arg_teams = rwmb_meta( 'ap-post-meta' );
- $query = new WP_Query( $query_args );
- if ( $query->have_posts() ){
- while ( $query->have_posts() ) : $query->the_post();
- $terms = wp_get_object_terms( $post->ID, 'league' );
- foreach ( $terms as $term ) {
- $league_title = $term->name;
- }
- //var_dump( $terms );
- $home_team_id = get_post_meta( get_the_ID(),'home_team',true );
- $home_team = get_the_title($home_team_id);
- $home_team_img_url = get_the_post_thumbnail_url($home_team_id,'full');
- // Away team meta
- $away_team_id = get_post_meta( get_the_ID(),'away_team',true );
- $away_team = get_the_title($away_team_id);
- $away_team_img_url = get_the_post_thumbnail_url($away_team_id,'full');
- $fixture_date = get_post_meta( get_the_ID(),'prediction_date',true );
- $fixture_time = get_post_meta( get_the_ID(),'prediction_time',true );
- $match_coef = get_post_meta( get_the_ID(),'prediction_coef',true );
- $link = get_the_permalink();
- $link_title = get_the_title();
- $thumbnail = get_the_post_thumbnail();
- if ( ! is_single() ) :
- $output[] .='<article class="argument-predictions">';
- $output[] .='<div class="entry-title"><a href="'.$link.'" title="'.$link_title.'"><div>'.$league_title.'</div></a></div>';
- $output[] .='<div class="row argument-predictions-container">';
- if ( '' !== get_the_post_thumbnail() && ! is_single() ) :
- $output[] .='<div class="col-md-3 post-thumbnail">'.$thumbnail.'</div>';
- $output[] .='<div class="col-md-9 argument-prediction-content">';
- $output[] .='<div class="col-md-4 team">';
- $output[] .='<div class="team-logo"><img src="'.$home_team_img_url.'" width="auto" height="auto"></div>';
- $output[] .='<div class="team-name">'.$home_team.'</div></div>';
- $output[] .='<div class="col-md-4 match-info">';
- $output[] .='<div class="starting-date"><span>'.esc_html__('Коеф', 'betinum').' - '.$match_coef.'</span></div>';
- $output[] .='<div class="starting-time">'.$fixture_time.'</div>';
- $output[] .='<div class="arg-prediction button"><a href="'.$link.'" title="'.$link_title.'">'.esc_html__('Към прогнозата', 'betinum').'</a></div></div>';
- $output[] .='<div class="col-md-4 team">';
- $output[] .='<div class="team-logo"><img src="'.$away_team_img_url.'" width="auto" height="auto"></div>';
- $output[] .='<div class="team-name">'.$away_team.'</div></div></div></div>';
- endif;
- $output[] .='</article>';
- endif;
- endwhile;
- wp_reset_postdata();
- }
- return sprintf(
- '<div class="arg-predictions-wrapper">
- %s
- </div>',
- implode( '', $output )
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement