我有这个简短的代码工作我无法在$quotelinks_atts
中显示part_template
吗?
function get_quotelinks_shortcode( $atts = [] ) {
//override default attributes with user attributes
$quotelinks_atts = shortcode_atts(['pulldownid' => '100',], $atts);
print_r(array_values($atts));
ob_start();
echo '<p>this shows fine' . esc_html__($quotelinks_atts['pulldownid'], 'get_quotelinks') . '</p>';
get_template_part( 'partials/quotelinks', 'shortcut', $atts);
echo '<p>athis hows fine' . esc_html__($quotelinks_atts['pulldownid'], 'get_quotelinks') . '</p>';
return ob_get_clean();
}
add_shortcode( 'quotelinks', 'get_quotelinks_shortcode' );
以下是我的partials/quotelinks-shortcut.php
文件
<?php
echo '<p>why doesnt it show' . esc_html__($quotelinks_atts['pulldownid'], 'get_quotelinks') . '</p>';
?>
<!-- i just see wha doesnt this show -->
<!-- all this works -->
<form class="form-horizontal quotelinkfrm">
<div class="form-group">
<div class="select-goto-holder col-xs-8 col-sm-8 col-md-10 col-lg-10 ">
<select class="goto form-control">
<option>choose</option>
<?php
global $wpdb;
$result = $wpdb->get_results("SELECT * FROM `wp_quotegroups` WHERE `disabled` = 0 ORDER BY `sort_order`");
foreach ($result as $optgroups) {
?>
<!-- etc -->
</form>