WP Slug自定义给出错误404 /未找到(POD自定义帖子类型)

时间:2020-05-02 07:49:46

标签: wordpress custom-post-type permalinks slug

我正在使用POD自定义帖子类型,并且已经在两种帖子类型之间创建了双向关系。 我的想法是,当两个自定义帖子类型之间存在关系时,获得一个自定义子弹: / custom-post-slug1 / custom-post-slug2 / post-title

所以我创建了这个函数:

function custom_post_slug ( $post_link, $post ) {

/* Pulling the relation post slug */
$quote_author = get_post_meta($post->ID, 'quote_author', true);
$quote_author['post_name'];

/* Condition for 'quote' post type */
if ( 'quote' != $post->post_type || 'publish' != $post->post_status ) {
    return $post_link;
}
/* Modifying slug */ 
$post_link = str_replace( '/' . $post->post_type . '/', '/' . $quote_author['post_name'] . '/' . $post->post_type . '/', $post_link );
return $post_link;

} add_filter('post_type_link','custom_post_slug',10,3);

该函数确实起作用(我可以看到该子弹已被修改,但在帖子页面上却找不到404 /...。)。我想念什么吗?

谢谢!

0 个答案:

没有答案
相关问题