Replace image with its alt text?

You should be able to use the the_content filter for this. Something like this… add_filter( ‘the_content’, ‘wpse418925_replace_images_with_alt’ ); function wpse418925_replace_images_with_alt( $content ) { // If you need to *only* do this on one post, check that we’re in that post. // $desired_post can be an ID, post title, slug, or an array of any of … Read more

Group users by meta field, with name of meta field as group title

i need to return/echo the name of the department/location for each group of employees That is actually a generic PHP/programming question, nonetheless, if you mean an output which looks like so: Location/Department Name – Employee/user – Employee/user – Employee/user Location/Department Name – Employee/user – Employee/user Then here’s one way of accomplishing that: Add this above/before … Read more

How do I load styles into the block editor admin screen?

The same way you do it for the classic editor, there’s a dedicated API for this: https://developer.wordpress.org/reference/functions/add_editor_style/ https://developer.wordpress.org/reference/functions/add_editor_style/#comment-1171: /** * Registers an editor stylesheet for the theme. */ function wpdocs_theme_add_editor_styles() { add_editor_style( ‘custom-editor-style.css’ ); } add_action( ‘admin_init’, ‘wpdocs_theme_add_editor_styles’ ); The block editor will read in your stylesheet, modify the rules so that they only apply … Read more

How to use webpack in WordPress theme? I want some scripts to load in the footer, some in the header and some with script parameters

What is the right and clean way to load these files in WordPress? The same way as you’ve always done it, wp_enqueue_script. WordPress is unaware that webpack created the javascript file, and it is just that, a javascript file. This is true wether it contains jquery, was written by hand, or was created by a … Read more

WordPress hack code issue, help required

This will try to load PHP code from one of three servers, the three base64-encoded strings, and execute the first one it successfully fetches on your server. Those domains do still exist, so this is potentially an active hack. They don’t return any data to me when tested but I hadn’t set a domain in … Read more

Too few arguments – wp_login action

The custom role needs the read capability to view the backend. Example: $your_role = get_role(‘your_custom_role’); $your_role->add_cap( ‘read’ ); See: https://wordpress.org/documentation/article/roles-and-capabilities/#read Ideally, this should only be done once, e.g. when activating your plugin or theme.

add_filter – create_function pb in PHP8

In general create_function should be replaced with a closure, like this: add_filter(‘excerpt_more’, function() { return “”; }); But in your specific case, you don’t even need that. WordPress has you covered already with a built-in function to use in a filter: __return_empty_string(). So you can just write: add_filter(‘excerpt_more’, ‘__return_empty_string’ );