Site logo

Archived topic

Styling gone once comments are disabled

5 replies · Started by Allen on July 27, 2021

Viewing posts 1–6 of 6

hi

The styling for my comments are gone once comments are de-activated after 14 days.
I used the PHP snippets here but it returned with an error probably due to my shared hosting setting.
Is there another way that I can style my deactivated comments?
Thank you!

Thanks the PHP snippet did't work for me, will have error. Probably due to very large comments database.

Anyway, I wish to apply some CSS styling to blog post that has DISABLED comments only, beside using post id.
Is there any way I can achieve this?

Thank you!

Hi Allen,

Let's modify the snippet a bit.

Can you try this?

add_action( 'wp_enqueue_scripts', 'manual_comments_style_enqueue' );

function manual_comments_style_enqueue(){
    if ( is_singular() && !comments_open() || get_comments_number() > 0 ) {
        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
        $dir_uri = get_template_directory_uri();
        wp_enqueue_style( 'generate-comments', $dir_uri . "/assets/css/components/comments{$suffix}.css", array(), GENERATE_VERSION, 'all' );
    }
}

Thanks! Your snippet is working fine!

Nice one. No problem. :D

This archived topic is closed to new replies.