comments_number doesn’t return the number of comments, it echos it out.
Use
get_comments_number()to retrieve the value.
Related Posts:
- Change comments form title on a page by page basis
- How do I create comment-reply-button using element not
- Replace comment avatars and links at the same time
- Adding ads code between comments
- How do I fetch all comments per post via WP REST API?
- Ajax load more button for comments wordpress
- Limit 1 global comment per minute
- Create Page To Count Comments For Each Post In WordPress Site
- wp-comments-post.php file returns a blank page
- php function to display commenter username or login
- Alter required message using comment form api
- Send a mail to specific address in a custom field when a new comment is made on a specific post
- Fetching Initials of the Commentator in the WordPress Website
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- Show all people who commented on all posts by an author
- How to get the rating value of each comment
- Trouble figuring out how to get my button to submit comment
- How to Add Image to WordPress RSS-Feed with no Plug-in?
- Display user’s total comment count outside The Loop
- WordPress Infinite Scroll without using any plugin
- How to remove a metabox from menu editor page?
- How to add active class to custom menu using while loop and wp_list_pages
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- WooCommerce – Display variation custom field value [closed]
- New Plugin Review
- Problems with function on function.php
- Woocommerce HTML email option unavailable
- Use template for posts with a particular category grandparent
- How to slow down server response
- How to add SVG icon above product tab title
- Function not working at one place
- How to prevent WP_Query function from returning all posts when empty?
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- foreach loop still echoes array
- dynamic dependent select dropdown
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- getting logged in user info (wp-load.php) from parent directory
- Add .htm extention to a custom taxonomy
- php syntax : [ && ] between commands [closed]
- Which PHP page is the Default Posts Page
- Need to put a script above tag in header.php – WP 5.7.1
- How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]
- How to show/hide php table rows based on the content of custom fields
- How to call multiple functions from multiple files into a WordPress page template [closed]
- get comment data using comment id
- Isotope Drop Down Categories Filter Function
- How to use array in function to get only value I want
- What is the best way to define constant options for a theme?
- add_filter function concatenate string and locate_template function
- Function for simple math doesn’t work what am I doing wrong? [closed]
- How to return a string that has a jQuery and Ajax inside in a shortcode?
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- get_page_templates only return templates with “home” in the filename
- Class property seems to lose scope, attached to save_post action?
- Nav-Menu not showing up
- Show different website layout if no sidebar added
- get_template_part function and add images
- Need advice on theme customizer and child themes
- How to make sure relative URL works when site is not on root domain?
- How to pass hook variable to function?
- exclude custom post type from running a function
- Migrating site, only header shows
- Change Language Title Pagination on Subdomain non Multisite
- remove specificly the last tag in all posts
- Let current user know pending posts counts using wp_query
- How to check post meta isset or not empty during publish/save post?
- how to changes mobile menu toggle breakpoint in WordPress
- How to use Page link field with is_page()
- How to hide a child category and show his parent category
- Gutenberg block don’t save rich text content
- remove_action from parent theme using child theme functions.php
- Change lost password url to a mailto URL in WordPress
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Remove span tags from WooCommerce Downloads page
- 500 Error, Get custom field and returning it
- How to add typehints to function in functions.php when argument is an object?
- is_user_logged_in() not working in homepage
- Custom Post type Ajax search results
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- str_replace not preserving whitespace
- How to set up an auto delete post?
- Display a post based on its metabox selection
- apply_filters() function
- Calling the Next category link on an archive page – WordPress
- Using tag to output text in Genesis?
- Metabox Input Not saving
- Custom action on comment post
- Cross origin ajax request always returns 0 when calling get_current_user_id();
- echo php values in table – strange behaviour, not all values are shown
- Merging two excerpt functions to work with conditions
- wp wp_register_script function results type parameter missing
- display php code in header using wp_head()
- Sorting Problem
- How to add different menu items on different menus?
- Function for Post Creation plugin for Gravity Forms
- Modify the permalink structure for a specific category
- Function extension
- Developing a “fallback” for empty wp_query results based on post dates
- How can I process a form submission from an HTTP POST request?