How to apply_filter / add_filter within 2 others (simultaneous?) add_filter

The ll/tracking_args filter is called by the track_conversion() method, and this function is added to the execution in the constructor of the CustomGF class. The GFChild class has its own constructor, so the constructor of the base class CustomGF is not executed. In the GFChild constructor also add track_conversion() function to ll/tracking_args filter or call … Read more

is_singular() in mu-plugins not working

When the active_plugins option is retrieved, WordPress does not yet know what page has been requested, so this approach will not work. In order to achieve your objective, you would selectively activate the plugin (rather than selectively deactivate the plugin), but this may cause problems and destabilize your site (untested): add_filter( ‘option_active_plugins’, static function ( … Read more

Get field added via attachment_fields_to_edit filter in Gutenberg

Yes, you’re right that the slimImageObject function is the reason why you’re seeing/getting only those limited list of props. But don’t worry, you can use wp.data.select( ‘core’ ).getMedia( <attachment id> ) to get the attribution meta (and any other meta or props in the full attachment object). Here’s an example that worked for me: items.map((item, … Read more

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

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’ );

Show only taxonomy types terms associated with a custom post type in WordPress PHP

UPDATE The custom SQL query below can be used to produce a list of unique types taxonomy terms that have been assigned to newsroom posts. In PHP, you can call the function get_newsroom_types_terms to get the list: $terms = get_newsroom_types_terms();. Custom SQL query function get_newsroom_types_terms() { global $wpdb; $table_prefix = $wpdb->prefix; $taxonomy = ‘types’; $post_type=”newsroom”; … Read more

How to change content hash value, within the_block_template_skip_link action?

If remove_action( ‘wp_footer’, ‘the_block_template_skip_link’ ) did not work, then try with remove_action( ‘wp_enqueue_scripts’, ‘wp_enqueue_block_template_skip_link’ );, or both of that. (see source on GitHub) As for changing the href value, I’m not aware of any (filter) hook to do that, but you can either edit your template and set the <main>‘s id value to content-top, or … Read more

Custom post type template not loading from plugin

I think your first method isn’t working because it’s a theme method, not a plugin method. I could be entirely incorrect but I think the method of using single-custom_post_type.php only works for themes. (Again, I 100% could be wrong.) However, this is what I use and it always works: function wpse_post_type_templates( $template ) { if( … Read more