我想通过函数从页面(不是帖子)中删除上次更新/上次修改的日期。php(这可以通过使挂钩为空来实现吗?)
目标是删除因日期修改代码而显示的google搜索结果描述日期时间戳。我只希望该函数在页面上运行(因为页面上次更新/创建的时间通常无关紧要)。
我意识到这可以通过修改页面模板中的底层代码来实现,但这种方法更容易实现。
谢谢
我想通过函数从页面(不是帖子)中删除上次更新/上次修改的日期。php(这可以通过使挂钩为空来实现吗?)
目标是删除因日期修改代码而显示的google搜索结果描述日期时间戳。我只希望该函数在页面上运行(因为页面上次更新/创建的时间通常无关紧要)。
我意识到这可以通过修改页面模板中的底层代码来实现,但这种方法更容易实现。
谢谢
这取决于模板用于输出您要删除的内容的内容。如果您在源代码中查看输出您想要删除的内容的任何函数,它们都有一个过滤器,允许您在可以的地方修改输出__return_false
但是,如果这些模板标记周围有文本或标记,则您唯一的选择是修改模板,最好通过子主题进行修改。
function wpd_remove_modified_date(){
if( is_page() ){
add_filter( \'the_time\', \'__return_false\' );
add_filter( \'the_modified_time\', \'__return_false\' );
add_filter( \'get_the_modified_time\', \'__return_false\' );
add_filter( \'the_date\', \'__return_false\' );
add_filter( \'the_modified_date\', \'__return_false\' );
add_filter( \'get_the_modified_date\', \'__return_false\' );
}
}
add_action( \'template_redirect\', \'wpd_remove_modified_date\' );
工作所需的所有代码:
function wpd_remove_modified_date(){
if( is_page() ){
add_filter( \'the_time\', \'__return_false\' );
add_filter( \'the_modified_time\', \'__return_false\' );
add_filter( \'get_the_modified_time\', \'__return_false\' );
add_filter( \'the_date\', \'__return_false\' );
add_filter( \'the_modified_date\', \'__return_false\' );
add_filter( \'get_the_modified_date\', \'__return_false\' );
}
}
add_action( \'template_redirect\', \'wpd_remove_modified_date\' );
我使用一个名为Code Snippets 在wordpress多站点安装中的所有站点上运行此代码。我想添加一个自定义字段(“introduction”和“ensavoirplus”)来搜索Wordpress,但SQL代码并不精确。我不明白我是否犯了错误,或者WP不能做到这一点。但我的尝试失败了。。。我不知道为什么,因为我完全按照抄本上说的去做。这是我的代码:function recherche_avancee( $query ) { if ( !is_admin() && $query->is_search ) { $custom_fiel