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
- Comment count next to post title?
- Get all comments of author’s posts
- Loop doesn’t show title of second post and posts thereafter
- How To capitalize The First Letter Of Every Word In The Post Title
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- SQL Command for restoring trashed comments
- Howto show comment count by post in post?
- How do you change the comment count in the back end posts list, to reflect unapproved comments, rather than all comments?
- How to show show the Second page title in the page
- 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
- Let both the admin and post author update comment meta
- How to make different custom post layouts?
- Is there any way to stylize articles one by one?
- Blog post not showing title
- Font shows up as Arial instead of Times [closed]
- How can I remove the first two words and shorten get_the_title()
- How do I include the category next to the title of a post?
- Replace image name on upload to the new post name on front-end form
- 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
- Change Post Title For Specific Category
- How to remove “» (title of post or page)”?
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- How can I add a class to particular paragraphs in my post?
- add div after image in post [closed]
- Auto update post title and slug when post status is changed
- How does WP decide how to display a page
- How do I switch css class on post
- Get featured image on hover of post title [closed]
- Display on page every post in blog WITH comments
- Microformats in a single post – layout conflict
- Showing recent post of category in page
- How do I display the post_title with get_permalink?
- Can WordPress handle following functionalities?
- Post titles and thumbnails as links to custom post types?
- displaying the categories post
- 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
- How do I apply a template to my single posts?
- How to implement a WordPress comments function?
- Changing The Default Header POST Title and Description text by category in wordpress
- Change modified date to current date when title updated automatically
- Allow / show post comments in category pages
- Indenting within a blockquote
- How to select a category automatically based on a word in WordPress post title?
- Different background colors for posts with WordPress
- Turn off display for custom sidebar post widget when on the post it’s displaying
- How to allow arbitrary inline CSS in posts?
- how to show current date on post title which should be auto update in every day
- Count the total views of all user posts published
- 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
- How to merge the content of posts that have the same title?
- Shortcode for Comments and Comment Boxes in Post Loop
- Merge get_comments & get_posts into a single query
- How to highlight or show new to the particular posts list
- Post title not displaying as recorded in the wp_posts table
- Css and function issue on author archive page
- WordPress Recent Post with the badge “New” on the side of the title post
- Remove the URL author of post on all comments
- Create/Set Category as Title of Post
- Centre Blog Index (Posts Page) on Home.php
- long-title posts do not want published
- WordPress weird behaviour on comments
- Comments are in database, don’t show up in WordPress backend or frontend
- I have two post types in the same query, how can I use CSS to select only one post type?
- No comments allowed
- how can i fix my display post in my index.php
- Please I want to prefix my WP posts title according to each category
- I want to change the WordPress comments file
- Add id attribute to h1 element of wordpress post
- Post title spoiler how?
- Odd hyphen added at end of blog post
- My posts page is missing the page title
- Hiding title of selected post without plugins
- 2 Domains, Same Content, Different Titles?
- Post Category link is same with Page link
- display content in multiple columns
- How can I alternate styling of images in a post? [closed]
- Posting a comment redirects admin/users to blank page
- How to enable comments meta box for other author posts?
- 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
- Comments as part of a post
- How to add a class to links inside posts text
- Add Image Before Posts Entry Title
- Some comment box wordpress in 1 post [closed]