php SHORTCODE:将TYPES地址字段显示为2行

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php SHORTCODE:将TYPES地址字段显示为2行相关的知识,希望对你有一定的参考价值。

// Shortcode to strip out everything past address from maps field
// 'location-address' needs to change to the field's slug you are separating into 2 lines
function display_types_address_into_2_lines(){
    $maps_address = types_render_field("location-address", array());
    list($address_line, $localities) = explode(',', $maps_address, 2);
    return $address_line."<br />\n".$localities;
}
add_shortcode( 'display-types-address-as-2-lines', 'display_types_address_into_2_lines' );

/*
 * Usage:  [display-types-address-as-2-lines]
 * Output: breaks up the address stored as a single line of the CPT 'Locations', fieldname "location-address" of Toolset Type's Custom Field -address type- into 2 lines;  address_line and localities
*/

以上是关于php SHORTCODE:将TYPES地址字段显示为2行的主要内容,如果未能解决你的问题,请参考以下文章

php 使用Shortcode和API密钥将Google Map嵌入到页面中

使用Shortcode获取自定义字段的值

使用Shortcode获取自定义字段的值

php 媒体查询ShortCode

php WP Shortcode加载远程内容

php 如何在Blooming中启用Shortcode