customization – Turn Autocomplete on

Question

Unfortunately, there’s no hook available to change it.

You can see it in wp-admin/edit-form-avanced.php:

<label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo $title_placeholder; ?></label>
<input type="text" name="post_title" size="30" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" spellcheck="true" autocomplete="off" />

You’ll have to change it using JavaScript when the page has been loaded.

I made a little plugin that will fix your issue. Here’s the code:

<?php
/**
 * Plugin Name: Autocomplete Title
 * Description: Sets the autocomplete attribute to true on WordPress post titles
 * Plugin URI: http://wordpress.stackexchange.com/q/175585/17305
 */

namespace WPSEAutocompleteTitle;

/**
 * Sets autocomplete attribute to true on WordPress post titles
 */
function set_autocomplete_on_title() {
    echo '<script>
    jQuery(document).ready(function($){
        if( $("#title").length ){
            $("#title").removeAttr("autocomplete");
        }
    });
    </script>';
}
add_action( 'admin_footer', __NAMESPACE__ . '\set_autocomplete_on_title' );

When you activate the plugin, it will remove the autocomplete attribute from the title’s <input>.

0
DarrenLee 6 years 2015-01-21T21:02:48-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse