Category: <span>php</span>

Saving posts programmatically after an import

I recently did a bulk post import for one of my sites and noticed that the related articles did not get set. Upon inspecting I found that saving the post manually in the backend did also set the related posts as desired. So I wrote some code to get posts by custom taxonomy and then auto save them all:

I suggest using WP Console to run this code – this external post explains how it works. Hope this helps you save some time the next time you need to autosave posts.

How to edit PHP values in WordPress and WooCommerce

PHP code is managed by your servers PHP settings
WordPress and WooCommerce PHP code can fail due to your servers PHP configuration. Some plugin’s PHP code require certain configuration values to be active, while some hosting providers may configure your servers PHP environment in a way that impairs execution.

Developers test their code using their configured local environments. Their server configuration often differs from what your hosting providers deems necessary.

Cannot save Custom Fields in WordPress backend

Sometimes custom fields fail to save. As a possible solution you can try and increase the max_input_vars which was introduced in PHP version 5.3.9. The default value for max_input_vars is 1000, which means that if your form has has more than 1000 inputs, any additional values will fail to save.

You can increase max_input_vars via your php.ini file:

max_input_vars = 3000

or via .htaccess document:

php_value max_input_vars 3000

And as always there is of course a plugin available that can help in checking your PHP version and editing your php.ini file.