我正在编辑Wordpress多站点以删除/修复损坏的链接 . 索引页面在主页上列出来自所有子博客的所有帖子,如磁贴 . 应用于作者姓名的链接不正确 .
我已经跟踪它并在content-single.php页面中生成一些代码来检索数据,其值为 %5$s
我认为它可能是一个正则表达式,但我可以't confirm. The value looks more like a shorthand expression for retrieving a variable from the database. Did a google search and still can't发现 . 我遇到了这个法典页面https://codex.wordpress.org/Function_Reference/get_the_category_list
我仍然无法找出 Value 观的含义 . 他们的意思是什么?
所以我对主题中的PHP文件进行了追溯 . 首先,我在'content-single.php'页面中看到了这个函数,它生成了包含错误链接的内容 <?php slqblogs_posted_on(); ?>
<div class="entry-meta">
<?php slqblogs_posted_on(); ?>
<span class="sep">|</span>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a href="http://www.addthis.com/bookmark.php?v=250&pubid=ra-4f836b545f19f0e0" class="addthis_button_compact">Share</a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4f836b545f19f0e0"></script>
<!-- AddThis Button END -->
<div class="clear"></div>
</div><!-- .entry-meta -->
很明显,我去查看'theme-functions.php'文件,我可以看到它的所有功能:
if ( ! function_exists( 'slqblogs_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
* Create your own slqblogs_posted_on to override in a child theme
*
* @since slqblogs 1.2
*/
function slqblogs_posted_on() {
printf( __( '<span class="posted-on"><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date published" datetime="%3$s" pubdate>%4$s</time><time class="updated">%8$s</time></a></span><span class="sep">|</span><span class="byline"> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'slqblogs' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'slqblogs' ), get_the_author() ) ),
esc_html( get_the_author() ),
esc_attr( get_the_modified_date() )
);
}
endif;
所以这就是我遇到byline的span类中的值的地方:
<span class="byline"> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>
只是无法弄清楚如何访问 %5$s
或其他关键字/表达式的值或它们是什么 .
老实说,这种Wordpress PHP脚本完全超出了我的深度和舒适区 . 任何帮助将不胜感激 .
2 回答
输出看起来像
它用于sprintf / printf格式描述符中的“交换”参数,即您可以按照您喜欢的顺序访问参数,例如:
版画
即使参数p1-p4已经以相同的顺序传递给
printf
s . 另见:http://docs.php.net/manual/en/function.sprintf.php#example-5403