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);
2 Answers
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):
- http://core.trac.wordpress.org/browser/branches/3.0/wp-includes/link-template.php#L166