0

I want to change the color of the protected post titles. When a post is in protected status (have password), the post title will turn red different from other posts. Please help me, thanks.

0

1 Answer 1

1

To change the color of password protected post titles in the admin

In your theme or child theme, enqueue a stylesheet to load in the admin, then add some simple CSS to change the color using the class that is given to password protected posts.

In your theme's functions.php...

function wpse_admin_styles(){

    wp_enqueue_style(
        'admin_css', 
        get_stylesheet_directory_uri() . '/css/admin-styles.css', array(), filemtime( get_stylesheet_directory() . '/css/admin-styles.css') 
    );

}

add_action('admin_enqueue_scripts', 'wpse_admin_styles');

Create a css directory in your theme, add the admin-styles.css and paste in the following CSS...

.post-password-required .row-title {
    color: red;
}

enter image description here

To change the color of password protected post titles on the frontend

In your theme or child theme add the following to your CSS files, or add it directly in Appearance > Customize > Additional CSS. It uses a class added to the article tag.

.post-password-required .entry-title {
    color: red;
}

enter image description here

Note - This may vary from theme to theme but should give you a good idea of how to do it.

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.