0
我正在面對wordpress的get_terms()函數的一個奇怪問題。Wordpress get_terms參數傳遞問題
<?php $x=1220;
$terms = get_terms("topics", 'hide_empty=0&parent=$x');
<ul class="ul1">
<?php foreach ($terms as $term) { ?>
<li><a href="<?php echo get_term_link($term->slug, 'topics'); ?>">
<?php echo $term->name; ?></a>
</li><?php }; ?> </ul>
沒有返回任何條款,但是當我用值1220,而不是直接的$ X,它返回的值。以下代碼正常工作。
<?php $terms = get_terms("topics", 'hide_empty=0&parent=1220');
<ul class="ul1">
<?php foreach ($terms as $term) { ?>
<li><a href="<?php echo get_term_link($term->slug, 'topics'); ?>">
<?php echo $term->name; ?></a>
</li><?php }; ?> </ul>
我需要使用變量,因爲我將從別處獲取術語ID。請告訴我這裏有什麼問題。