1
我有以下功能:如何正確放置PHP呼應裏面的html span標籤
<?php
function my_custom_address ($formats) {
$formats = array(
'default' => '<span class="my-address-country"></span>
<span class="my-address-city"></span>'
);
return $formats;
}
add_filter('default_address_formats', 'my_custom_address', 15) ;
?>
而且我試圖把跨度標記中的以下的輸出:
$listing_address_country = get_my_field('address_country');
echo $listing_address_country;
$listing_address_city = get_my_field('address_city');
echo $listing_address_city;
最接近我想出了以下內容:
function my_custom_address ($formats) {
$listing_address_country = get_my_field('address_country');
$listing_address_city = get_my_field('address_city');
$formats = array(
'default' => echo '<span class="my-address-country">' . $listing_address_country . '</span>';
echo '<span class="my-address-city">' . $listing_address_city . '</span>';
);
return $formats;
}
add_filter('default_address_formats', 'my_custom_listing_address', 15) ;
但它仍然不正確。我知道我很接近,但我似乎仍然錯過了一些東西。
那偉大工程,非常感謝! –