I am trying to change the link of the "View Post" button that appears next to the "Change Permalinks" button above the editor on post edit screens for a custom post type.

I have altered all the messages when a post is updated, published etc. but cannot figure out how to alter the button link. I'll need to do this for the "Preview" button as well. The custom post type is not publicly queryable so I need my client to be able to click these buttons and be taken to the page that displays this custom post type (using a page template).

Any and all help is appreciated!


»View Post« Button

There's a filter that you can use with a simple str_replace. Not the best solution, but there's no other one:

apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug)

»Preview« Button

For the »Preview« Text, there's not filter (only for the link target), but you can take a look at this Answer by @toscho on how to use the gettext filters for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.