php - 如何从 Wordpress 中的特定单页中删除标签?
问题描述
我正在尝试<!--nextpage-->
从我的 single.php 内容文件中删除标签,但它会显示其他单个文件,如 single-post1.php 或 single-post2.php。我尝试使用 is_singular 函数,但是当它进入 if 条件时,它会全局重置所有内容,我该如何处理它的特定文件。
add_action( 'the_post', function( $post )
{
if(is_singular() && 'post' == get_post_type() && 'post1' != get_post_type() && 'post2' != get_post_type() ){
if ( false !== strpos( $post->post_content, '<!--nextpage-->' ) )
{
// Reset the global $pages:
$GLOBALS['pages'] = [ $post->post_content ];
// Reset the global $numpages:
$GLOBALS['numpages'] = 0;
// Reset the global $multipage:
$GLOBALS['multipage'] = false;
}
}
}, 99 );
谢谢你的帮助....
解决方案
推荐阅读
- swiftui - iOS 13 中 SwiftUI 中的状态栏高度
- neo4j - Neo4j:(弱)连通分量算法,只选择一个分量
- python - 从类属性列表中删除字典
- java - 无法为 SqlServer 连接器设置 debezium 嵌入式引擎
- python - Django - GeoDjango 以错误的顺序读取坐标
- angular - Angular 9 路线儿童无法进行导航
- python - MyPy 和显式检查
- redux - Redux - 从不同的文件更新具有相同功能的存储
- maven - 为什么maven测试依赖包含编译依赖?
- html - 带有图标的 HTML/CSS 响应式按钮