在part_template中使用Wordpress Shortcode atts

时间:2017-01-09 10:50:02

标签: php wordpress

我有这个简短的代码工作我无法在$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>

0 个答案:

没有答案