All Questions (5,600 questions)



Where can I find documentation on what characters are allowed in user names and why?

Posted by Prem Tiwari | Updated on

I don’t think there’s any official documentation about that, but you can have a look at the sanitize_user function in wp-includes/formatting.php: You could hook into that function and override the default behavior with your own.

Is it possible to override the result of get_template_part()?

Posted by Prem Tiwari | Updated on

I think it’s not exactly possible the way you want to achieve. It’s really annoying to not getting a filter there to alter template files names. I have a workaround on it though. Let use …

How to store widget fields data as an array?

Posted by Prem Tiwari | Updated on

Here is a very simple demo widget:

Where is the old post permalink slug stored?

Posted by Prem Tiwari | Updated on

We determined that the slug was not stored in postmeta meta_key _wp_old_slug. In a final attempt to find where this slug is stored. I performed a search for the exact phrase of writing and found a few results. The one …

Where to securely store API keys and passwords in WordPress?

Posted by Prem Tiwari | Updated on

There is no absolutely safe way to store such information permanently. You have two options to increase security a little bit: Use the options table and encrypt the data Use a strong encryption method, and bind …

Is there a way to set default custom fields when creating a post?

Posted by Prem Tiwari | Updated on

Is there a way to set default custom fields when creating a post? This is the proper method to add custom fields support (you don’t get the blank fields when edit posts)

Do something after sending email

Posted by Prem Tiwari | Updated on

Do something after sending email. I did some digging into the PHPMailer class and found that it supports a custom action. Here’s how the callback is activated with the doCallback() method in the class. There’s also a PHPMailer test on GitHub using this feature …

Understanding add_rewrite_rule

Posted by Prem Tiwari | Updated on

Understanding add_rewrite_rule. A basic rule that would work for your example: This takes whatever comes after foo/ and sets that as pagename for the query, and then param gets the static value foo. If you …

What is the Advanced $context in add_meta_box?

Posted by Prem Tiwari | Updated on

What is the Advanced $context in add_meta_box? The difference between normal and advanced is that normal will be placed on the page before advanced. For example the following will display “One” before “Two” If you …

Redirect Main Site to Subsite in Multisite WordPress

Posted by Prem Tiwari | Updated on

Redirect Main Site to Subsite in Multisite WordPress. You can use the parse_request action to accomplish this. Simply enable this plugin on your primary blog. Place the following code in a .php file and upload …

WooCommerce assign an author to a product

Posted by Prem Tiwari | Updated on

WooCommerce assign an author to a product. Simply use add_post_type_support:

Setting WPLANG from a plugin

Posted by Prem Tiwari | Updated on

Setting WPLANG from a plugin. In wp-includes/l10n.php you will find the function get_locale(). It offers a filter; you can set the language and ignore the constant: To change it per plugin use the filter ‘locale’. …

Move excerpt meta box to above content editor

Posted by Prem Tiwari | Updated on

Move excerpt meta box to above content editor. It’s simple, just unregister postexcerpt box first then add another one on the top. Here is my code:

Deactivate Gutenberg tips forever – not Gutenberg

Posted by Prem Tiwari | Updated on

Gutenberg tips can be disabled by using dispatch(‘core/nux’).disableTips() (NUX package) and action hook enqueue_block_editor_assets. Use the below example code in your functions.php file: Now use the below example code in your custom JS file:

Change CSS/formatting on specific page, but not pages in general?

Posted by Prem Tiwari | Updated on

After creating the specific CSS you need to format the page how you like, you could: Create a custom page template with the CSS and assign the template this page. Create a page-{slug}.php file with the CSS, …