wp.media multiple selection limit

As far as I know, that feature is not officially supported, so there is no easy way to achieve it. But if you must, then it can be made possible by extending the wp.media.model.Selection.prototype.add function which is used to add new items to the selection list. Working example: (tried & tested with WordPress v6.2.2) ( … Read more

Search for portfolio tags & mixing portfoliotags and post tags

It sounds like you’re encountering several issues with customizing search and tag functionalities in WordPress, particularly concerning portfolio and blog posts. Let’s tackle each point step by step. Filtering Search Results to Include Only Posts and Portfolio Posts Your initial function in functions.php is almost correct, but it seems to be improperly filtering the post … Read more

Multiple 404 Pages

Yes, it’s definitely possible to have multiple 404 pages for different purposes on a WordPress site, although it requires a bit of custom coding. You can achieve this by detecting the source of the 404 error and then redirecting to a specific 404 template based on the condition. Here’s a general approach to implement this: … Read more

Override base Gutenberg block default spacing in child theme’s theme.json

Use a Global Styles Filter to override the style: add_filter( ‘wp_theme_json_data_default’, function ( $theme_json ){ $new_data = array( ‘version’ => 2, ‘styles’ => [ ‘blocks’ => [ ‘core/embed’ => [ ‘spacing’ => [ ‘margin’ => [ ‘top’ => ‘2rem’ ] ] ] ] ] ); return $theme_json->update_with( $new_data ); }); An alternative that may also … Read more

How to I serve the static HTML file at the root directory in a wordpress site?

I needed the same thing – a ‘landing’ page at the root site that was custom-built (via PHP), but then WordPress-based pages elsewhere. I did it with the htaccess file for the site: # For example.com root, set landing.php as the default page RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] RewriteRule ^$ /landing.php [L] This will redirect www.example.com … Read more

Can plugin authors make db tables remain upon deactivation, but be removed upon plugin deletion?

Yes, there is a difference and it is possible for a plugin to know when it is deactivated or deleted. For deactivation the plugin may register a deactivation callback using register_deactivation_hook(). For deletion the plugin may either register a deletion callback using register_uninstall_hook() or include a uninstall.php file in its base folder. There’s an important … Read more