【问题标题】:Storing single_tag_title in variable将 single_tag_title 存储在变量中
【发布时间】:2013-04-18 06:27:41
【问题描述】:

在 Wordpress 中,以下内容将在存档列表中回显当前选择的标签:

single_tag_title();

有谁知道如何将它存储在一个变量中,这样我就可以使用这样的普通 php 变量来回显相同的字符串:

echo $tagSlug; //This shows the same string as the single_tag_title() function

我试过这个:

$tagSlug = single_tag_title();
echo $tagSlug;

但它不起作用。

【问题讨论】:

    标签: wordpress variables tags echo archive


    【解决方案1】:

    single_tag_title 接受两个参数。 $前缀和$显示。 $prefix 设置应该在标签之前回显/返回的字符串,$display 确定标签是回显还是作为变量返回。见the documentation here

    $tagSlug = single_tag_title("", false);
    echo $tagSlug;
    

    【讨论】:

      猜你喜欢
      • 2021-06-22
      • 2017-04-04
      • 2013-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-24
      • 2017-07-11
      • 2011-12-10
      相关资源
      最近更新 更多