在 php/wordpress 中打印时如何从文本中删除锚标记
我试图弄清楚如何删除将打印单词包装到 html 页面的锚标记。 Suchas:
<a href="something">blog</a>
相反,简单地说:
blog
我认为这与这两者有关:
%1$s
并且主要与我的代码的这一部分有关:
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
我创建了一个新函数。
现在只是想弄清楚为什么 %1$s
生成类别名称的锚标记版本而不是纯文本格式?
我认为这也部分与此有关: = __
不太确定。因为正常的类别引用:%s
也无法代替 %1$s
。
if ( ! function_exists( 'designconcepts_posted_under' ) ) :
/**
* Prints HTML with title information for the current single post (category title).
*
* @since Design Concepts 1.0
*/
function designconcepts_posted_under() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
$posted_in = __( '%1$s', 'designconcepts' );
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = __( '%1$s', 'designconcepts' );
} else {
$posted_in = __( '%1$s', 'designconcepts' );
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
}
endif;
I'm trying to figure out how tor remove the anchor tag that wraps a printed word to the html page. Suchas:
<a href="something">blog</a>
instead to be just simply:
blog
I reckon it has something to do with both this:
%1$s
and mostly this part of my code:
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
I made a new function.
Now just trying to figure out why %1$s
produces the anchor tag version of the category name instead of just the plain text format instead?
I'm thinking it partly has to do with this as well: = __
Not too sure. Cause the normal Category reference: %s
does not work either in place of %1$s
.
if ( ! function_exists( 'designconcepts_posted_under' ) ) :
/**
* Prints HTML with title information for the current single post (category title).
*
* @since Design Concepts 1.0
*/
function designconcepts_posted_under() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
$posted_in = __( '%1$s', 'designconcepts' );
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = __( '%1$s', 'designconcepts' );
} else {
$posted_in = __( '%1$s', 'designconcepts' );
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
}
endif;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试过“strip_tags”吗?
http://php.net/manual/en/function.strip-tags.php
Have you tried "strip_tags"?
http://php.net/manual/en/function.strip-tags.php