我需要用逗号来清理WordPress标题,因为它使用逗号来替换空格。
我用过这个但对我没用
echo sanitize_title_with_commas("the_title");
我的意思是:如果这是主标题this is WordPress forum
当我使用代码时,它将成为this,is,wordpress,forum
提前谢谢。
我需要用逗号来清理WordPress标题,因为它使用逗号来替换空格。
我用过这个但对我没用
echo sanitize_title_with_commas("the_title");
我的意思是:如果这是主标题this is WordPress forum
当我使用代码时,它将成为this,is,wordpress,forum
提前谢谢。
根据您输出标题的方式,答案是不同的。但有两种可能性。
wp_title();
wp_title();
its中的函数header.php
文件,您可以使用wp_title
滤器但是,自4.4以来,该函数一直被弃用。add_filter( \'wp_title\', \'filter_the_title\' );
function filter_the_title( $title ) {
$title = str_replace( \' \', \',\' , $title);
return $title;
}
add_theme_support( \'title-tag\' );
pre_get_document_title
筛选以执行此操作。add_filter( \'pre_get_document_title\', \'filter_the_title\' );
function filter_the_title( $title ) {
$title = str_replace( \' \', \',\' , $title);
return $title;
}
我想知道帖子缩略图是否需要“Alt title”,如“title”,以及如何将其添加到我的相关帖子查询中。。。我正在使用以下代码获取帖子缩略图:<div class=\"td-module-thumb\"> <a href=\"<?php the_permalink(); ?>\" title=\"<?php the_title_attribute(); ?>\"> <?php if (has_post_thumbnail()) {&#