我目前正在编辑一个 Wordpress 多站点以删除/修复损坏的链接。索引页面在主页上列出了所有子博客中的所有帖子,作为磁贴。应用于作者姓名的链接不正确。
我已经对其进行了跟踪,并且在 content-single.php 页面中生成了一些代码来检索数据,其值为%5$s
我认为这可能是一个正则表达式,但我无法确认。该值看起来更像是从数据库中检索变量的速记表达式。谷歌搜索了一下,还是找不到。我遇到了这个法典页面https://codex.wordpress.org/Function_Reference/get_the_category_list
我仍然无法找出这些值的含义。他们的意思是什么?
所以我对主题中的 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;
所以这就是我在跨行类中遇到值的地方:
<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 脚本完全超出了我的深度和舒适范围。任何帮助将不胜感激。