我在 VC 中设置了一个自定义元素,供用户添加一个带有自定义文本、链接和(自定义)字体图标的按钮。
我可以回显标题和链接,但字体图标是空白的。当我 print_r($atts) 我得到这个:
Array
(
[reach_vc_button_text] => More Information
[reach_vc_button_link] => url:http%3A%2F%2Flocalhost%2FWordPress%2FJammyCustard%2Freach%2Ffunding%2Fthriving-rural-communities-scheme-trc%2F|||
[reach_vc_button_icon] =>
);
<?php
function reach_vc_button_html( $atts ) {
$atts = shortcode_atts(
array(
'reach_vc_button_text' => '',
'reach_vc_button_link' => '',
'reach_vc_button_icon' => '',
), $atts, 'reach_vc_button'
);
ob_start();
?>
<?php
$href = $atts['reach_vc_button_link'];
$button_link = vc_build_link( $href );
//echo '<pre>'; print_r($atts); echo '</pre>';
?>
<a href="<?php echo $button_link['url']; ?>" class="read-more excerpt-read-more project-read-more"><?php echo $atts['reach_vc_button_text']; ?><i class="<?php echo $atts['reach_vc_button_icon']; ?>"></i></a>
<?php
$html = ob_get_clean();
return $html;
}
add_shortcode( 'reach_vc_button', 'reach_vc_button_html' );
编辑:添加参数代码:
array(
"type" => "iconpicker",
"heading" => __( "Button Icon", "reach-rdp" ),
"param_name" => "reach_vc_button_icon",
"value" => "icon-more-information",
"description" => __( "Select the icon to display for this button", "reach-rdp" ),
"settings" => array(
"emptyIcon" => false,
"type" => "reach",
"iconsPerPage" => "50",
),
"dependency" => array(
"element" => "icon_type",
"value" => "reach",
),
),