I don’t see any reason why pre_get_comments
would not be working, it’s still in core, however…
you’ve got a few problems in your code –
do_action_ref_array
is what core calls to trigger the action, you add your own functions to the action queue via add_action
.
orderby
is the field name you want to order by, order
controls how it’s ordered, and ASC
and DESC
are the only valid values for order
.
WP_Comment_Query
returns an array of comments, you could use PHP’s shuffle to randomize the order.
Also note that you have curly typographer quotes in your code above around orderby
and rand
, which will throw a PHP fatal error. You do have debugging enabled, yes?
Related Posts:
- Writing a plugin that notify my friends of new post that mentions(@) them
- Why are two functions over-riding each other?
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- comment_email hook doesn’t seem to work for comment editor field
- Show comments fields in two columns
- preprocess_comment array doesn’t have comment_ID
- How do I alter the comment form ‘allowed tags’ text in a plugin?
- Can wp_list_comments output into variable?
- Comments do not respect display_name setting, how to make plugin to overcome this
- $reverse_top_level works the opposite way according to Codex?
- How to integrate CLEditor to comment system?
- Get attachments from a post
- How to replace default comments with custom HTML?
- Custom avatars in wordpress comments?
- how to load the comment template from a plugin
- How to get the number of pages when paginating comments?
- How does “Your comment is awaiting moderation” work?
- how to get the top 10 popular blogs
- disable defaault wordpress comments from a plugin
- How to show comments from different Plugins to same post type?
- How to check if `comment_meta` exists before inserting the comment?
- How to get the `comment_post_ID`?
- Email content as comment
- Stop theme displaying comments
- Get Commentor IP When Marking Comment As Spam
- isset($_POST[‘submit’]) ignored on comment submission
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How to output message during plugin activation
- On the WordPress Admin section how do I link to submenu pages created for a plugin?
- How to provide translations for a WordPress TinyMCE plugin?
- Where do I start from
- Where is it better to start learning how to develop for WordPress?
- Check the Version of an Enqueue’d External Library
- Is there any way to test if a function running only on plugin update is successfully running?
- Change of query var in pre_get_posts not maintained
- Hook for post permalink update
- Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page
- How to Parse an Array of Elements in Gutenberg Block
- Load page template with custom content using a plugin
- How to put placeholder text in the main post input area?
- Will changing the ‘Plugin Name’ header in the next update of a plugin break anything?
- Performance of several get_option() calls
- How to edit mySQL wp_posts table from plugin php?
- Creating a Wordpess Plugin that writes data to a csv file. The data doesn’t show in the csv file?
- Problem with is_active_sidebar?
- Prevent Plugin from loading on ‘wp-admin / wp-login’
- Redirect user to a particular link in 10 seconds after using wp_die
- Getting admin notices working for plugin errors
- Change template dynamically
- override pluggable.php functions
- An echo line in a transition_post_status action leads to “cannot modify header information – headers already sent by”
- “Plugin could not be activated because it triggered a fatal error.”
- Add column in WP user but it goes wrong
- How to remove the current post from the query?
- Passing nonce at admin menu link
- Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?
- how to get up row in wordpress with wpdb
- Preview plugin store details
- How to remove default style of header in wordpress metabox
- TEMPLATEPATH without the theme name? No THEMEPATH constant?
- wp_update_post deletes post meta in CPT
- Update Data parameter of a wp_localize_script() call
- UWooCommerce – add cart discount programmatically?
- Bad Request in AJAX
- Remove sidebar on single page using plugin API
- When does save_post hook fire on post save/update
- Enqueuing scripts and styles in custom plugins
- Include file in plugin file
- Shortcode not appearing when used as post content in wp_insert_post() or possibly, shortcode not being registered at all
- Adding custom stylesheet into header.php using a plugin
- Developing the save function in Gutenberg blocks
- Detect change in site_url and home_url
- Adding Custom CSS with PHP
- How to remove/replace current page template?
- Add a Custom Field in Comment Box next to the Text area
- Is there a way to add a link with add_post_meta?
- How to receive notification of deprecated API elements and functions?
- Using password protection to load different page elements?
- How to Show Category List With Corresponding Links?
- .htaccess with WordPress – create my own pretty url with parameters (above WordPress settings)
- Generating a password-protected front-end page via a plugin
- How do I add a 5 digit ZIP code validation to a Contact7 form?
- wp_remote_post not working with admin-post.php
- How can we stop showing short code in create or edit post section
- Default media uploader is not showing in wordpress website
- Delete Plugin Options with Verify
- Load custom translation in custom plugin fails
- Buddy Press restrict the capability to edit users
- “Headers Already Sent” Nightmare on Plugin
- Uncaught ReferenceError: kpoejy is not defined
- How to get an array out of a nav menu if it’s a plugin?
- Is there better way to do this without duplicating queries?
- How to create a simple plugin which show/hide an html code in wordpress?
- How to create custom frontend php page via plugin
- Translation of plugin Upload button
- Create wordpress dashboard metabox which spans all columns
- add_filter adds output in the head
- How can i add insertion point between inner blocks in my custom block like core blocks
- Update option hook not firing
- Programmatically creating posts based on external JSON feed (asynchronously)