WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] CSS for only removing "Comments Off" ? (16 posts)

  1. IslandOwl
    Member
    Posted 2 years ago #

    Is there a way with CSS to make it so the Comments show if you have comments but do not show "COMMENTS OFF". When I have posts or pages with comments turned off I don't need that statement there. I would like it to show nothing.

    Way down near the bottom of this discussion @thejiggerypokery supplied the php code to do what I want it to do but if I can change it in CSS that would be preferred.

    I would like to set it so it displays as follows:

    if no comments, displays --> Leave a comment »
    if 1 comment, displays --> 1 comment »
    if more than one comment (e.g. 5), displays --> 5 comments »
    css class --> not defined
    if comments are off, displays --> is blank

    The php code to make it do that is:
    <?php comments_popup_link('Leave a comment »', '1 Comment »', '% Comments »', '', ''); ?>

    Ps. I am using the Brunelleschi Theme too. GREAT theme!

  2. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    This content is generated by WP through the PHP code in use and output as HTML on the page...the manner to change the output properly is to modify the php, preferably in a child theme.

  3. orpatech
    Member
    Posted 2 years ago #

    it depends on your theme.. can you share a link to your site? or a demo version of the theme which have posts with "comments turned off"

  4. IslandOwl
    Member
    Posted 2 years ago #

    Or, even better, is there a way to make "COMMENTS OFF" not show up on a post by post basis? - because it is really only my sticky post that I want to remove it from.

  5. IslandOwl
    Member
    Posted 2 years ago #

  6. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    there is no distinctive css selector if the comments are off; best solution is to edit the php code as suggested.

    btw:
    formatting belongs into style.css - not into the content or template files. at the moment it is showing in your site.

    however, if you know the post ID, you can use css to hide the comments link for individual posts;
    example to be added into style.css:

    .post-155 .entry-utility { display:none; }

  7. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Yes, this can be done per post:

    Admin Dashboard>Posts>All Posts>Hover over the post>Click 'Quick Edit'>Uncheck 'Allow comments'>Save>Clear server cache if in use.

  8. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    it is really only my sticky post that I want to remove it from

    that makes it easy, as your theme uses post_class() which adds a css class of .sticky to the post div;

    in style.css, add:

    .sticky .entry-utility { display: none; }

  9. IslandOwl
    Member
    Posted 2 years ago #

    Thank you alchymyth. That is a great idea to just put the css in for that one post.

    If I do want to change the php, what file would I find it in? I have looked and cannot even see where "COMMENTS OFF" is being generated, nor "Leave a Comment". It is not in the comments.php nor the functions.php.

    I am not sure what you mean by "formatting belongs into style.css - not into the content or template files. at the moment it is showing in your site." unless it was that I had just out of curiosity tried to see if I could use css on that first post - but it showed up in the post. You may have caught it right then for the minute it was there.

    Thank you Swanson Photos but on many themes (Brunelleschi Theme which I am using) when you uncheck 'Allow Comments' instead of that just leaving a blank space the theme puts in "COMMENTS OFF" and it is that very thing that I am trying to get rid of.

  10. IslandOwl
    Member
    Posted 2 years ago #

    Awesome alchymyth!! That worked!

    (We were writing at the same time so ignore the post above this one. But I am still curious where that php code is located.)

  11. IslandOwl
    Member
    Posted 2 years ago #

    One more question though. What could I put in that would remove the date on just the sticky post - remove that whole line of "Posted On"?

  12. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    in the same way:

    .sticky .entry-meta { display: none; }

  13. IslandOwl
    Member
    Posted 2 years ago #

    THANK YOU!! And now, since it is 2:45am, I am going to call it a night!

  14. IslandOwl
    Member
    Posted 2 years ago #

    Then would title be:
    .sticky .entry-title {display:none;}

    I am sorry, I don't know where to find what the different areas are called. I tried looking in the codex but must not be asking the question clearly enough.

  15. IslandOwl
    Member
    Posted 2 years ago #

    Answered me own question! I tried it and it worked!

    Thank you again for all your help tonight!

  16. IslandOwl
    Member
    Posted 2 years ago #

    This is resolved. Forgot to check that two weeks ago.

Topic Closed

This topic has been closed to new replies.

About this Topic