admin管理员组

文章数量:1417442

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.

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.

Share Improve this question edited Aug 6, 2019 at 19:16 RiddleMeThis 3,8078 gold badges22 silver badges30 bronze badges asked Aug 6, 2019 at 18:49 Duy HữuDuy Hữu 195 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 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;
}

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;
}

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

本文标签: wp adminChange the color of the Password Protected Post titles