老实说,我必须查看源代码才能为您找到正确答案。
此特定筛选器的问题是$filter 零件是动态的,因此您必须知道要修改的特定频率。有很多选择:
homepage,
blogpage,
$post_type . \'_archive\',
$post_type . \'_single\',
$c->taxonomy . \'_term\',
author_archive.
因此,一旦您确定了要修改的特定过滤器(我选择了一个主页),您就可以将以下内容添加到您的功能中。php
add_filter( \'wpseo_sitemap_homepage_change_freq\', \'my_custom_homepage_freq\', 10, 2 );
function my_custom_homepage_freq( $default, $url ) {
return \'hourly\';
}
正在更改
author_archive 也很简单,因为您要替换
$filter 过滤器名称中的部件
author_archive.
如果$post_type . \'_single\' (或另一个$post_type 在名称中),您必须替换$filter 使用post\\u类型名称。Eg仅适用于页面:
add_filter( \'wpseo_sitemap_page_single_change_freq\', \'my_custom_page_freq\', 10, 2 );
function my_custom_page_freq( $default, $url ) {
return \'hourly\';
}
让你明白什么可以代表
$filter 在你最初的问题中,我必须检查
./inc/class-sitemaps.php 文件(可以在Subversion:
http://plugins.svn.wordpress.org/wordpress-seo/trunk/inc/class-sitemaps.php ) 其中第578行是调用的函数
filter_frequency 然后构造过滤器。该功能
filter_frequency 正在从文件中调用几次,并且包含
$filter 这是第一个论点。例如:
$this->filter_frequency( \'homepage\', \'daily\', $this->home_url )