这是用于显示与 wp_ai1ec_events 相关的相应帖子的插件代码
function draw_event($atts ) {
global $wpdb;
$event = $wpdb->get_results("SELECT * FROM wp_ai1ec_events ORDER BY start");
foreach ( $event as $events )
{
$events1=$events->post_id;
$wpdb->show_errors();
$list=$wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID =$events1");
$url = site_url();
$title=str_replace(' ', '-', $list->post_title);
$title=str_replace('/', '', $title);
$start = explode(" ", $events->start);
$end = explode(" ", $events->end);
$img_src=wp_get_attachment_image($events1);
$result.=$img_src."<p><strong><a style='color:#FFF' href='".$url."/ai1ec_event/".$title."' >".$list->post_title."</a></strong></p> <img src='".$img_src."'/> Start date:".$start[0]."<br> Time:".$start[0]."</br>End date:".$end[0]."<br> Time:".$end[1]."<br><br><br>";
}
return $result;
//print_event($events,$list);
}
add_shortcode( 'listtheevent', 'draw_event');
现在我想展示相应帖子的特色图片。我正在使用 wp_get_attachment_image($events1); 为了这。但这不起作用
有什么建议吗?谢谢