Help to cleanup this code

时间:2014-06-21 作者:ProStone

我正在尝试更改我的附件页链接yo

example.com/photos/attachment_ID/post_name/attachment_name
你能告诉我怎么称呼家长的帖子吗

    function wpd_attachment_link( $link, $post_id ){
    $post = get_post( $post_id );
    $parent_post = get_post($parent_post_id);
    $rewrite_link = $post->post_name;
    $parent_post_name = $parent_post->parent_post_name;
    $home_url ->rules = \'/photos/\' . $post->ID . "/$rewrite_link" . "/$parent_post_name";
    return $home_url->rules;
}
add_filter( \'attachment_link\', \'wpd_attachment_link\', 20, 2 );

1 个回复
SO网友:Pieter Goosen

get_post 返回aWP_Post 对象,以便可以使用$post->post_parent. 您应该查看WP_Post 链接

结束

相关推荐