迁移网站后,我的Wordpress出现问题。在标题标记中(<title>
) 我有"–"
而不是"-"
对于浏览器来说,它很好,在标题中它显示良好。但在html代码中"–"
....
请帮帮我<;3.
迁移网站后,我的Wordpress出现问题。在标题标记中(<title>
) 我有"–"
而不是"-"
对于浏览器来说,它很好,在标题中它显示良好。但在html代码中"–"
....
请帮帮我<;3.
–
), 直接引号到卷曲引号以及其他一些类似的符号和标点符号到其打印机友好版本,使用wptexturize
.一般来说,建议将其留给WordPress。然而,偶尔,我们可能希望忽略这种行为。例如,如果我们正在编写编程代码或命令,并希望人们复制粘贴它们。
<code></code>
块这样,WordPress就会知道它们应该保持原样。然而,我们可能已经写好了,不想重写。在这种情况下,可以通过禁用wptexturize
.对于WordPress 4.0及以上版本,在插件或主题中使用以下代码很容易functions.php
文件:
add_filter( \'run_wptexturize\', \'__return_false\' );
对于WordPress 4.0之前的版本,您需要更多的代码:foreach( array(
\'bloginfo\',
\'the_content\',
\'the_excerpt\',
\'the_title\',
\'comment_text\',
\'comment_author\',
\'link_name\',
\'link_description\',
\'link_notes\',
\'list_cats\',
\'nav_menu_attr_title\',
\'nav_menu_description\',
\'single_post_title\',
\'single_cat_title\',
\'single_tag_title\',
\'single_month_title\',
\'term_description\',
\'term_name\',
\'widget_title\',
\'wp_title\'
) as $texturize_disable_for )
remove_filter( $texturize_disable_for, \'wptexturize\' );
当然,您可以选择禁用wptexturize
仅用于部分内容。例如,仅为禁用title
, 您可以使用:remove_filter( \'the_title\', \'wptexturize\' );
确保传递给wp_title();
函数包装在esc_html();
示例:
<title><?php esc_html(wp_title($YOURSTRINGHERE)); ?></title>
我将RichText API用于自定义块:<RichText tagName=\"a\" className=\"button\" placeholder={ __( \'Button text...\' ) } value={ buttonText } onChange={ ( value ) => setAttributes( { buttonText: value } ) } /> 我正在使用a 作为标