WordPress.org

Ready to get started?Download WordPress

Forums

Change default button on post.php to "Publish" (3 posts)

  1. Callum Macdonald
    Member
    Posted 8 years ago #

    When writing a new post (post.php) the default button is "Save" not "Publish". It was Publish in previous versions of WordPress and I'd like to change it back.

    I've tried various searches on this forum and found nothing, Google through up a few links to this forum but nothing has led me to the answer. Can anyone tell me how to do this?

    Just to clarify, I don't want to change the default "Post Status" under the "Post Status" heading. I'd like the option to hit the "Save" button and have my post saved as a draft, just as it worked prevoius to version 1.5.

    Many thanks,

    Callum.

  2. MichaelH
    Member
    Posted 8 years ago #

    In 1.5.2, if you were using Advance Controls, the Save button was the default and Draft was the default Post Status. So advanced controls what 2.0.2 uses.

    With that said, in Version 2.0.2, you can could change wp-adminadmin-functions.php at approximately line 299

    from
    $post->post_status = 'draft';

    to
    $post->post_status = 'publish';

    That will Publish a Post if either the Save or Publish button is clicked. I didn't do much heavy testing of that ...

    --------------------
    Please note that modifying core files is generally discouraged, so make a backup of the file(s) before changing anything--just in case it doesn't work you'll have something to fall back on. Also, remember you will need to 'retrofit' that change upon subsequent WordPress upgrades.
    --------------------

  3. Callum Macdonald
    Member
    Posted 8 years ago #

    MichaelH: Thanks for that, I had found a few posts on the forum about changing the default post status. What I want to do is change the default button, not the status, so I can still choose to hit "Save" and save the post as a draft.

    I had a look in the source, and it turns out that the default button is actually the one which appears first, so that's normally "Save and Continue Editing". I've changed the tab order and set the Publish button to be bold, which is what makes it appear to be the default.

    For reference, the changes are in /wp-admin/edit-form-advanced.php

    Line 45 change:
    tabindex="3" to tabindex="4"

    Line 199 change:
    tabindex="4" to tabindex="5"
    and remove "style="font-weight:bold;"

    Line 204 change:
    tabindex="5" to tabindex="3"
    and then add "style="font-weight:bold;" immediately after the code you've just changed

    This changes the tab order so when you press tab in the content text area it will automatically take you to the "Publish" button. However, in editing all this code I realise that you can simply use the shortcut "P" (Alt-P on Windows/Firefox).

    Enjoy, Callum.

Topic Closed

This topic has been closed to new replies.

About this Topic