I know it sounds like a Basic Question and I did google first. Google lead me to edit /wp-admin/edit-form-advanced.php to put target='_blank' there. I did that, but this doesn't seem to affect the 'view page' button on the top of the edit page site. I want it to open in a new tab every time.

In what file/where can I find that button? Can you give advice on how to systematically search such a location for the future?

What is the proper way of doing that and why.

Thanks for letting me know

2 Answers 2


Firstly it is best to not edit your wordpress core files inside wp-admin but rather modify them with filters/actions and hooks. Check the wordpress codex to see all the filters you could use. Here is the code for a filter that you can put into your theme functions file (/wp-content/themes/{the-theme-you-are-using}/functions.php) to make the view post use target="_blank"

function my_get_sample_permalink_html($a){
    return preg_replace("/<span id='view-post-btn'><a/","<span id='view-post-btn'><a target='_blank'",$a);

No need to make this a hook process in WordPress. Let the jQuery library leverage some of the work that is not necessarily needed in the WordPress system, and in my opinion, this would be one of these times.

Within your custom JavaScript file, target the anchor link that lives on that edit post page and either inject a target attribute or class (on hover add target to element). In better words, make this a dynamic javascript enhancement for your button.

You can then save all your hook processing for what is truly needed in WordPress.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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