Our Blog

Rewrite Custom Post Type (CPT) Permalinks


add_filter( 'post_type_link', 'wpse16427_post_type_link', 10, 4 );
function wpse16427_post_type_link( $post_link, $post, $leavename, $sample )
{
	if(in_array($post->post_type, array('blog', 'news-article', 'action-funnel', 'bookmark','positon-camp')))
    {
        $authordata = get_userdata( $post->post_author );
        $author = $authordata->user_nicename;
        $post_link = str_replace( '%author%', $author, $post_link );
    }
    return $post_link;
}

Leave a Comment

Your email address will not be published. Required fields are marked *

Recent Posts

Scroll to Top