我已经在我的WordPress网站的PHP文件中的一个下面的代码:简单的PHP/WordPress的语法问题
<?php if (count(get_the_category())) : ?>
<span class="cat-links">
<?php printf(__('<span class="%1$s">• Posted in</span> %2$s', 'twentyten'), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list(', ')); ?>
</span>
<?php endif; ?>
它的作用是输出所有类别的逗号分隔,链表,一个特定的帖子属于。例如,输出如下所示:
张贴在组别,类别2,类别3
我想要做的就是修改此行的开头也包括笔者。据WordPress的文档中,作者姓名可以使用检索:
get_the_author()
但我不熟悉PHP语法不够好,弄清楚如何将它添加到我的本钱。以下是我想它,而不是阅读:
张贴在组别,类别2 author_username,类别3
任何帮助将不胜感激!
这完美的作品 - 非常感谢!最后一个问题......它显示了作者的名字,但并没有像链接类别那样链接它......我如何去做它呢? – Iconoclast
您可以使用'get_the_author_link()'而不是'get_the_author()' –
看起来应该可以工作,但我仍然无法将它链接到作者名称。它与if语句中的内容有什么关系?这里是我现在得到的(我用你的建议也将日期添加到帖子行)'<?php printf(__(' •发布于%2 $ s由(),get_the_date(),get_the_author_link(),get_the_category_list(','));%3 $ s in%4 $ s','twentyten'),'entry-utility-prep entry-utility-prep-cat-links' ?> – Iconoclast