Use have_comments()
function.
Example:
<?php if ( have_comments() ) : ?>
<h2 class="has-comments"><a href="https://wordpress.stackexchange.com/questions/363222/<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php else : ?>
<h2><a href="https://wordpress.stackexchange.com/questions/363222/<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php endif; ?>
Related Posts:
- How to Orderby Comments by post title?
- Is there a way to specify an extra class for a post or page with no title?
- If post exists, make it a comment in existing post with same name?
- Hide title in Merlin Theme on posts and pages only
- Apply the_title() filter in post & page title, but not in menu title
- Allow variable amount of comments before pagination
- get comments and get posts in loop
- Dynamically update post title in admin page
- How to show posts rank based on custom field value
- One comment per user email per post
- Can’t show comments count per post outside loop
- Only display posts with comments
- How to output comments number of a post per day?
- Hide comments awaiting moderation from user who submitted the comments
- Displaying Page Title on index.php
- Hide add new page button
- How to intercept Post Title on Post-Save
- How to add a custom field after wp post
- How To Keep Posts from Being Displayed Two or More Times on My Homepage? [closed]
- Display posts with comments closed, with pagination?
- How Can i Get 5 Recent Post Title With Corresponding Link?
- Latest 5 posts (custom post type), each post different CSS
- How to prevent WordPress from updating the modified time?
- Posts vs. Pages
- How to allow logged in users to post anonymously
- Style Differently Edited Posts
- Query get post,how to add comment box
- CSS: How can I show a photo beyond the template’s column, but contained within the browser window? [closed]
- Enable Comments Box On Custom Post Type
- Turn On Comments On Custom Post Types in Directory Theme
- Can I search posts and pages for css classes?
- Showing author page if user has no post
- How to add tags (custom taxonomy) to post class css?
- How do I change the core post search algorithm? Where is it found/constructed?
- What do comments with […] mean?
- How to remove in-line style of WordPress’s post content only?
- Internal post link creates comments on its own
- Show comment number per author per day
- Add title for previous and next posts to Yoko Theme
- Get all comments of author’s posts
- SQL Command for restoring trashed comments
- Every second post different class in blog view
- How to get links to the last N posts in a specific category?
- Make a vertical dynamic list of posts in alphabetically order and in columns [closed]
- Create a list of posts with topic headdings
- Hide comments and posts posted by other user
- How to make different custom post layouts?
- How do I include the category next to the title of a post?
- Edit the post title from the frontend
- Why in my query is display two title?
- Image behind the post’s title
- My Custom Post Type Still Using index.php
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- add div after image in post [closed]
- How do I switch css class on post
- Get featured image on hover of post title [closed]
- How do I display the post_title with get_permalink?
- Can WordPress handle following functionalities?
- How to separate each individual blog post?
- How to get post id of last approved comment?
- Locally change the font family [closed]
- YARPP php question
- Right align a youtube video
- Allow / show post comments in category pages
- Indenting within a blockquote
- How to allow arbitrary inline CSS in posts?
- Adding Text after Post Title based on Category using IF Condition – But not for menu items
- how to show comments only author which send own posts in wordpress
- Merge get_comments & get_posts into a single query
- Css and function issue on author archive page
- WordPress Recent Post with the badge “New” on the side of the title post
- I have two post types in the same query, how can I use CSS to select only one post type?
- I want to change the WordPress comments file
- My posts page is missing the page title
- Hiding title of selected post without plugins
- How can I alternate styling of images in a post? [closed]
- How can I choose and change a post title at random from an array when it is published?
- Post title to show all characters after having it limited for preview
- Add Image Before Posts Entry Title
- Some comment box wordpress in 1 post [closed]
- Background image in posts
- prevent same wordpress post title
- Trash a post, send associated comments into the trash bin (change status)
- Get post title by Alphabet
- How can I get a comment ID on Submit?
- Get first comment link on the post itself
- Get url/link to latest comments in a post
- Display only posts with comments
- Is it possible to have different header style blog titles in different categories?
- 2 tick boxes appearing below comments
- display only the title of the post into a certain category
- How do I show the post title if an advanced custom field hasn’t been used?
- Deleting first four characters from all Post Titles
- clicking on page title
- Change a div background color on Post ID
- Title displaying multiple times
- How can I show the positive and negative comments for a same post separately?
- Custom Post-Rename Function Does Not Function in WordPress 6.x
- How to change Post title background size?
- Simple shortcode to check if a user has commented on a certain post