我想修改自定义帖子类型的重写规则,tribe_events
, 在“事件日历”核心插件文件(The-Events-Calendar.class第24行)中注册为post类型:
protected $postTypeArgs = array(
\'public\' => true,
\'rewrite\' => array(\'slug\' => \'event\', \'with_front\' => false),
\'menu_position\' => 6,
\'supports\' => array(\'title\',\'editor\',\'excerpt\',\'author\',\'thumbnail\', \'custom-fields\'),
\'capability_type\' => array(\'tribe_event\', \'tribe_events\'),
\'map_meta_cap\' => true
);
我想做的是修改行:
\'rewrite\' => array(\'slug\' => \'event\', \'with_front\' => false)
收件人:
\'重写\'=>数组(\'slug\'=>\'事件/%lugares%\',\'with\\u front\'=>false)
其中,“%lugares%”是自定义分类法的名称。
然后,我的计划是使用以下函数来完成重写过程:
add_filter(\'post_type_link\', \'events_permalink_structure\', 10, 4);
function events_permalink_structure($post_link, $post, $leavename, $sample)
{
if ( false !== strpos( $post_link, \'%lugares%\' ) ) {
$lugares_term = get_the_terms( $post->ID, \'lugares\' );
$post_link = str_replace( \'%lugares%\', array_pop( $lugares_term )->slug, $post_link );
}
return $post_link;
}
问题是我不想修改核心插件文件。是否有一种方法可以在我的主题函数中的单独函数中修改自定义post类型重写参数。php??
谢谢