【发布时间】:2015-05-27 18:15:23
【问题描述】:
我正在尝试将高级自定义字段插件简码用作另一个简码中的属性。
制作我的主题的公司目前不提供定制支持。
原始简码列在此
public function plan( $atts, $content )
{
$html = array();
extract( shortcode_atts( array(
'price' => '',
'price_info' => '',
'type' => '',
'delay' => '',
'class' => '',
), $atts ) );
$html[] = '<div class="' . ( $class ) . '">';
$html[] = '<div class="plan has-animation" data-delay="' . ( (int)$delay ) . '">';
$html[] = '<div class="plan-container">';
$html[] = '<ins class="plan-price">' .( $price ) . '</ins>';
$html[] = '<span class="price-info">' . ( $price_info ) . '</span>';
$html[] = '<h2 class="second_color">' . ( $type ) . '</h2>';
$html[] = do_shortcode( $content );
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
return implode("\n", $html);
}
当我调用简码 [pt_plan price="$12.99" price_info="per month" type="Standard" delay="400" class="col-lg-4 col-md-4 col-sm-4"] 时,我想让价格属性允许简码作为值来利用高级自定义字段。
但是,如果我将 [acf field='session_price_1'] 作为属性值,像这样,[pt_plan price="[acf field='session_price_1']" price_info="per month" type="Standard" delay="400" class="col-lg-4 col-md-4 col-sm-4"] 就好像这是一个字符串并破坏了原始的 pt_plan 短代码。
有人能指出我正确的方向吗?我以为是在计划简码中将do_shortcode() 添加到 $price 变量中,但它不起作用。
希望这一切都有意义,并在此先感谢!
【问题讨论】:
标签: wordpress advanced-custom-fields