Comment count next to post title?

On most cases you should be able to use the_title filter to modify the title string. Use get_comments_number() to get the comments count for the post – of given ID or the current one. For example, add_filter( ‘the_title’, ‘wpse_427277_the_title’, 10, 2 ); function wpse_427277_the_title( string $title, $post_id = null ): string { $comment_count = (int) … Read more

Add Imports to Existing WordPress Import Map

Turns out to be quite simple in WordPress 6.5. Use wp_register_script_module to register the imports, and include them as dependencies in wp_enqueue_script_module: add_action(‘wp_enqueue_scripts’, ‘enqueue_three_d_script’); function enqueue_three_d_script() { wp_register_script_module( ‘three’, “https://unpkg.com/[email protected]/build/three.module.js”, array(), null ); wp_register_script_module( ‘three/addons/’, “https://unpkg.com/[email protected]/examples/jsm/”, array(), null ); wp_enqueue_script_module( ‘three-d-script’, SCRIPTS_DIR . ‘threeDTest.js’, array(‘three’, ‘three/addons/’), null ); }

How to add custom field to top of WordPress Comment Form for both logged in and anon users

I think you could use the comment_form_field_comment() filter to add the custom HTML before the main comment field. The filter is fired for both visitors and loggedin users. add_filter( ‘comment_form_field_comment’, ‘wpse_426971_comment_form_field_before’ ); function wpse_426971_comment_form_field_before( string $field ): string { return sprintf( ‘<p>%s</p>%s’, is_user_logged_in() ? “I’m logged in” : “I’m not logged in”, $field ); } … Read more

Hide Description field for custom taxonomy?

The term edit view uses edit-tag-form.php to render the editing form. The description field is hard-coded in the file without any filters or actions to control its visibility. So I’m afraid you’ll have to resort to css/js solutions. If you’re feeling adventurous, you could disable the default UI for the custom taxonomy, register custom submenu … Read more

I have to select text from gutenberg editor. Purpose is to store and replace text

We have to select text from the Gutenberg editor. The purpose is to store and replace text. Please use this code to help us with you const { select } = wp.data; const selectedBlock = select(‘core/block-editor’).getSelectedBlock(); if (selectedBlock) { const selectedText = selectedBlock.attributes.content; console.log(“Selected Text:”, selectedText); // Store the selectedText as needed. } Replacing Text … Read more

dashboard_activity hook

Using the dashboard_recent_posts_query_args filter, you can add your custom post types to the query args, and they’ll be included (untested): add_filter( ‘dashboard_recent_posts_query_args’, static function ( $args ) { if ( ! is_array( $args[‘post_type’] ) ) { $args[‘post_type’] = array( $args[‘post_type’] ); } $args[‘post_type’][] = ‘cpt’; return $args; } );

tech