Question

How can I change the page that the 'view' action links to on the list post screen for a custom post type?

Update

I've got it to work with normal post types using the below code but where do I define the custom post type?

function change_link($post_url,$post) {
    return '/video?id='.$post->ID;
}
add_filter('post_link',"change_link",10,2);
Was it helpful?

Solution

By adding a filter to the 'post_link' hook. See the get_permalink() function for more info.

For custom post types, you can use the 'post_type_link' hook.

It's a lot easier if you follow the source code (this is for v3.0):

OTHER TIPS

Based on the update of your question:

function change_link( $permalink, $post ) {
    if( $post->post_type == 'video' ) { // assuming the post type is video
        $permalink = home_url( 'video?id='.$post->ID );
    }
    return $permalink;
}
add_filter('post_type_link',"change_link",10,2);
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top