Why am I getting an error when requiring a file in my plugin?

As the names suggest, plugin_dir_path() will get the filesystem path, while plugin_dir_url gets the URL. A file path looks something like this /var/www/html/wp-content/plugins/my-plugin/ and can be used by PHP to find a file on the server. A URL will look like https://www.example.com/wp-contents/plugins/my-plugin/ and is intended to be accessed over the web. If you attempt to … Read more

How to detect if we are in the Site Editor part of the Block Editor (as opposed to editing a Page/Post) in JavaScript?

The Block Editor, in both the context of the editing pages or the Site Editor, actually does provide some simple variables in JavaScript similar to the data that is available via get_current_screen in PHP. Sample variables in Page Editor: var ajaxurl=”/mysite/wp-admin/admin-ajax.php”, pagenow = ‘page’, typenow = ‘page’, adminpage=”post-new-php”, thousandsSeparator=”,”, decimalPoint=”.”, isRtl = 0; Sample variables … Read more

Pages resolve at different URLs (different capitalizations)

Have you moved servers recently? In years past, Windows servers always treated them differently than on unix servers. Barring that, you can edit your .htaccess file to convert all URLs to lowercase. Here’s a guide editing depending if you have access to httpd.conf file or not; https://www.rewriteguide.com/apache-enforce-lower-case-urls/ As suggested by @Rup, a canonical URL should … Read more

Theme template file for a specific custom taxonomy

Is it possible to create a file specific for custom taxonomy itself? Yes, it’s possible in WordPress. So for the custom post type (music) I’ll create single-music.php for displaying the music alone right? That is correct. and taxonomy.php for displaying the single taxonomy content/value like rap, tupac, greatest-hits right? That is also right. but how … Read more

Twenty-Twenty-Two Child Theme Mega Menu

For the ‘Everything’ submenu, you can target it and then set the width to simply fit the content. nav.wp-container-2 li.wp-block-navigation-item.has-child ul.wp-block-navigation__submenu-container { width: fit-content; } This worked for me on StackBlitz, but you may need greater specificity (MDN) to target the element in your project. Note that you can also flag it as important (MDN) … Read more