我有一个奇怪的输出问题。这是我的代码:
add_shortcode(\'publish_party\', \'party_contact_suppliers\');
function party_contact_suppliers(){
$alerts = new WP_Query (array (
\'post_type\' => \'alert\',
\'post_status\' => \'publish\'));
$address_cache = get_option( \'toolset_maps_address_coordinates\' );
// Ballito
$home_lat = -29.4872902;
$home_lon = 31.1613188;
echo \'<h3>Ballito</h3>\';
echo \'<ol>\';
while($alerts->have_posts()) {
$alerts->the_post();
$id = get_the_ID();
$author = get_the_author();
$author_id = get_the_author_id();
$emailaddress = the_author_meta(\'user_email\',$author_id);
$center_location = get_post_meta($id,\'wpcf-center-location\',true);
$radius = get_post_meta($id,\'wpcf-radius\',true);
$lat = 0;
$lon = 0;
foreach ($address_cache as $key => $value) {
if ( $value[\'address_passed\'] == $center_location ) {
$lat = $value[\'lat\'];
$lon = $value[\'lon\'];
break;
}
}
$distance = distance($lat,$lon,$home_lat,$home_lon);
echo \'<li>\';
echo \'<p>Alert Post ID: \'.$id.\' Author Name:\'.$author.\' Author ID: \'.$author_id.\' Email Address: \'.$emailaddress.\'</p>\';
echo \'<p>Author location: \'.$center_location.\' Lat: \'.$lat.\' Long: \'.$lon.\' Distance: \'.$distance.\'Kms</p>\';
if ($distance <= $radius) {
echo \'<p style="color:green">Distance is within radius of \'.$radius.\' Kms. Send email to \'.$emailaddress.\'</p>\';
}
else { echo \'<p style="color:red">Distance is not within radius of \'.$radius.\' Kms.</p>\';}
echo \'</li>\';
}
echo \'</ol>\';
wp_reset_postdata();
}
这是输出:
警报帖子ID:611作者姓名:测试作者ID:3电子邮件地址:作者地址:南非昆斯堡马尔文迪普代尔路Lat:-29.882405长:30.911583距离:50.122577927515km
距离在100公里的半径范围内。发送电子邮件至
[email protected]警报帖子ID:609作者姓名:magicbygav作者ID:4电子邮件地址:作者地址:Ridge Close,Sweetwaters,Hilton,South Africa Lat:-29.600001长:30.2936253距离:84.868679439733公里
距离不在25公里的半径范围内。
[email protected]警报帖子ID:599作者姓名:Gavin作者ID:1电子邮件地址:作者地址:南非阿曼齐姆托蒂谷景路Lat:-30.0617324长:30.8777186距离:69.492657639933km
距离不在50公里的半径范围内。
我不明白为什么电子邮件地址出现在列表项上方,而不是我希望找到它的两个地方。有人能看到这里出了什么问题吗?