How do I load css in edit screens for the block builder?

To load a custom stylesheet for the WordPress admin screens that manage posts and use the block editor, you can use the admin_enqueue_scripts hook to enqueue your stylesheet. Here’s an example of how you can achieve this: First, create a custom stylesheet (let’s call it admin-custom-styles.css) and place it in your theme or plugin directory. … Read more

add_post_meta unique value for all custom posts

you can use the save_post hook to validate the uniqueness of email and phone fields before saving the post. Replace seller with your actual post type slug and add below code in functions.php file // Add custom meta box for Seller post type function add_seller_meta_box() { add_meta_box( ‘seller_meta_box’, ‘Seller Details’, ‘render_seller_meta_box’, ‘seller’, ‘normal’, ‘default’ ); … Read more

wordpress.com vs local install

Specifically regarding the iframe discrepancy – Jacob Peattie was right in the comments. This was caused by jetpack’s builtin blocks not being registered with version 3. Once I disabled them via Jetpack -> Settings -> Writing -> Composing and unchecking “Jetpack blocks give you the power…”, the iframe appeared as expected. Here’s the link explaining … Read more

Set Featured Image of a post

To set a featured image when creating a post using wp_insert_post(), you can use the set_post_thumbnail() function // Create the post $post_id = wp_insert_post($args); // Check if the post was created successfully if (!is_wp_error($post_id)) { // Set the featured image if ($image_url) { // $image_url should be the URL of the image you want to … Read more

Error logging in wordpress

You’ll find error_log output in WordPress’s debug.log, under wp-content, if enabled in your web server’s error log file, e.g. /var/log/httpd/error_log for Apache, or /var/log/apache2/error_log on Ubuntu /var/log/nginx/default-error.log for nginx or in your PHP FPM service’s error log if you’re running that instead It generally won’t get output in the web page, no. If you want … Read more

Possible to issue a warning before plugin deletion (i.e., that tables will be deleted)?

When a user decides to uninstall a plugin in WordPress, it’s up to the plugin author to define what actions should be taken during the uninstallation process. This can be achieved by setting up a callback function for the uninstall hook (or providing an ‘uninstall.php’ file within the plugin’s directory): register_uninstall_hook( __FILE__, ‘my_plugin_uninstall_callback’ ); function … Read more

Fatal error after update 6.5 – wp-includes/media.php:2134 svg inline sizes equal 0

If you dig into the function wp_img_tag_add_width_and_height_attr, you see the line where it goes wrong: $size_array[1] = (int) round( $size_array[1] * $style_width / $size_array[0] ); Before this there are two places to do something. The first is a filter to bypass generating any widths and heights, which you could use like this: add_filter (‘wp_img_tag_add_width_and_height_attr’, ‘wpse424749_no_height_width’); … Read more