The issue is caused by the arguments for separate_comments
being passed by-reference. Source: function separate_comments(&$comments)
. This means passing a function as an argument is restricted.
To resolve the issue you need to assign the get_comments
function results to a variable.
$comments = get_comments('status=approve&post_id=' . $id);
$comments_by_type = separate_comments($comments);
return count($comments_by_type['comment']);
Related Posts:
- How does printf( __( ) ); work?
- Displaying Logged-In User Name in WordPress Menu
- How to set custom cookies before output
- Change the filename format of saved featured images
- How to use wp_insert_user on WordPress Multisite?
- On this day PHP code
- How do I add a php statement to a jQuery string
- Upload images and attachments from frontend form
- Config apple-app-site-association file with wordpress
- How to use the php if statement [closed]
- Should I use wp_mail or PHP’s mail? [duplicate]
- Successful or Error Message after running mysql code in functions.php
- How can one utilize a variable as a callback function name for add_settings_field
- Link to file in plugin directory from wordpress template?
- Insert array data on plugin activation
- Auto crop images in WordPress
- Trying to make php run in a post
- Adding Default Settings to Theme My Login plugin
- How to add values to media “whitelist_options” in wp-admin/options.php template?
- WordPress Site Running Extremely Slow on Dedicated Server
- Where Does WordPress Make cURL Requests? How To Add cURL Option
- How to use an associative array in post__in with WP_Query?
- Extract 1st word of blogname/insert in middle of new string
- Can you run WordPress on a MarketLive/Java EE server?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- filter default query to show just selected level of child pages in wordpress
- Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
- Set meta field to publish date + 2 weeks
- Redirect undesirable domain
- WordPress Gravatar filter is removing my custom attributes
- How to make my custom widget appear within WordPress widgets? Plugin development
- Refresh table data with Ajax
- Trying to install wordpress locally with mamp, but have unsupported php version
- Incorrect amount of posts returned when filtering related Woo products by custom taxonomy
- PHP code to use on next & previouspage links
- How to optimize the IF condition with many conditions and same output [closed]
- Show latest posts in a plain HTML website custom widget [closed]
- How to list posts from a plugin taxonomy?
- How to remove coupon dropdown feature
- Theme not calling Jquery properly
- Creating Database Table vs. Adding MetaData to Post & User
- How to put a form with php code into a variable or shortcode?
- WordPress redirect redirecting too many times or not at all
- how to prevent wordpress admin from logging in via woocommerce my-account page
- Add html link in functions.php files of the theme
- how can i add class or span tag at sprintf?
- WordPress meta_query >= &
- Change header on pages displaying taxonomy items
- Listing titles and custom fields of entries within subcategories
- WordPress site with embedded menu – gives You don’t have permission to access /wp-content/themes/xxx/taxonomy-redirect.php on this server
- Must filter functions receive all arguments passed to them?
- Prevent Company Name From Translating
- Displaying Slider in Front Page (home) using Customizr Theme
- Usage of var keyword in the core
- How to add PHP pagination to wordpress
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- PHP displaying wrong custom taxonomy images
- Slow site initial load time
- MySQL Query Returns Array () In Shortcode
- array wordpress when get is null
- Custom search query on WordPress page not working
- PHP session not staying alive. headers already sent
- how can I call a function when time expire
- Google CSE Malfunctions via Chrome/Safari on Mobile When Clicking on Either Search Icon/Menu Icon. How to Make Google CSE Default Theme Search
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Get Child of Child Pages in custom Menu
- Latest posts feed with a specific post always first
- Filter by Post Type
- WordPress Post undefined error with Post Date (New to Wordpres Dev)
- Move Jquery.js to Footer
- Updating the database after parsing CSV document
- Need help to create WordPress page that decodes a text file and publishes it in JSON format
- My blog posts section seems to be rendering the other blog posts inside the first? :/
- How to get total gross revenue for current month in the woocommerce dashboard status widget
- Attaching an upload to a user
- Change home_url in searchform.php to go to HTTPS instead of HTTP
- can’t grab PHP $_POST variable
- Ajax Load more CPT via shortcode
- Loop 1 user randomly
- Wp_mail doesnt work
- Use WP_Query Data In Cookie
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- Sort by multiple options in custom field
- Is custom behaviour possible when asynchronously uploading?
- How can I show only if custom field has content [closed]
- Top menu disapears in Category Pages when filtering using ACF
- doubled content
- Adding if statement to content for homepage
- Tables not showing divs and loop/php items
- Keeping the previous get value and add another value when submitted
- Pagination not displaying
- How to add active class dynamically
- Setting WooCommerce currency programmatically
- Masking external links with internal link for member-only
- I’m not able to get access $wpdb in my php file in wordpress
- Submit cf7 form to cfdb as pdf/BLOB [closed]
- advanced custom fields: repeater field within conditional statement [closed]
- please on skin.php on theme wordpress option fix on theme option to not print empty variables and empty
- How to pass value to add_filter wpcf7_form_tag from another function?
- Custom nav with bootstrap dropdown