有一个问题,现在我将详细描述。该站点在整个周期中都有一个模板输出事件。我怎样才能不通过div?我附加了循环代码和浏览器中显示的代码。帮帮我))
$html .='<div class="qodef-events-list-holder-outer '.$classes.'" '.$data_atts. '>';
$html .='<div class="qodef-events-list-holder clearfix">';
if($query_results->have_posts()):
while ( $query_results->have_posts() ) : $query_results->the_post();
$current_id = get_the_ID();
$params['title'] = get_the_title($current_id);
$params['date'] = get_post_meta($current_id, 'qodef_event_item_date', true);
$params['link'] = get_post_meta($current_id, 'qodef_event_item_link', true);
$params['target'] = get_post_meta($current_id, 'qodef_event_item_target', true);
$params['tickets_status'] = get_post_meta($current_id, 'qodef_event_item_tickets_status', true);
$html .= qodef_core_get_shortcode_module_template_part('events','events-list-template', '', $params);
endwhile;
else:
$html .='<p>' . esc_html__( 'Sorry, no events matched your criteria.','qodef-cpt' ) . '</p>';
endif;
$html .='</div>';
if($show_load_more == 'yes'){
$html .= qodef_core_get_shortcode_module_template_part('events','load-more-template', '', $params);
}
wp_reset_postdata();
$html .='</div>';
return $html;
<div class="qodef-events-list-holder clearfix">
<div class="qodef-event-content qodef-events267">
... some code
</div>
<div class="qodef-event-content qodef-events267">
some code
</div>
<div class="qodef-event-content qodef-events267">
some code
</div>
</div>
代码应如下所示。有人可以帮忙吗?
<div class="qodef-events-list-holder clearfix">
<table> //start table
<tr><div class="qodef-event-content qodef-events267">
... some code
</div></tr>
<tr><div class="qodef-event-content qodef-events268">
... some code
</div></tr>
<tr><div class="qodef-event-content qodef-events269">
... some code
</div></tr>
</table> //finish table
</div>
答案 0 :(得分:0)
if($query_results->have_posts()):
$html .= '<table>';
while ( $query_results->have_posts() ) : $query_results->the_post();
$current_id = get_the_ID();
$params['title'] = get_the_title($current_id);
$params['date'] = get_post_meta($current_id, 'qodef_event_item_date', true);
$params['link'] = get_post_meta($current_id, 'qodef_event_item_link', true);
$params['target'] = get_post_meta($current_id, 'qodef_event_item_target', true);
$params['tickets_status'] = get_post_meta($current_id, 'qodef_event_item_tickets_status', true);
$html .= '<tr><td>' . qodef_core_get_shortcode_module_template_part('events','events-list-template', '', $params) . '</td></tr>';
endwhile;
$html .= '</table>';
else:
$html .='<p>' . esc_html__( 'Sorry, no events matched your criteria.','qodef-cpt' ) . '</p>';
endif;