WP_MEMORY_LIMIT or WP_MAX_MEMORY_LIMIT ?

the more you know

By default, WordPress enforces a memory limit of 40 MB. This means a single PHP script is allowed to use up to 40 MB of RAM. In certain cases, you may need to increase WordPress’ memory limit to run heavier plugins like WooCommerce or bbPress. To increase WordPress’ memory limit, you can define WP_MEMORY_LIMIT in your wp-config.php file using the line below.

define( 'WP_MEMORY_LIMIT', '256M' );

The setting above will allow WordPress to use up to 256 MB of RAM for each script, as long as the memory_limit setting in your php.ini file is 256 MB or greater. As is often the case with computing resources, setting a higher memory limit doesn’t necessarily increase the performance of your WordPress site. Since WP_MEMORY_LIMIT controls memory allocation PER SCRIPT, it’s actually in your best interest to set it as low as possible to reduce the chance of a rogue script saturating the RAM in your server.

Sometimes, it’s a good idea to tailor WordPress’ memory allocation separately for the frontend and backend. That’s where WP_MAX_MEMORY_LIMIT comes in. WP_MAX_MEMORY_LIMIT allows you to set a different memory limit for WordPress’ administration dashboard. This is useful because certain administration tasks require more RAM. Below is an example of how you can use WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT together.

define( 'WP_MEMORY_LIMIT', '64M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M');

The setting above will allocate up to 64 MB of RAM per PHP script for processes spawned from WordPress’ frontend, while administration-related scripts from the backend dashboard will be able to use up to 256 MB of RAM.

WordPress Menu target=_blank

How to open external menu links in a new tab with WordPress?
When creating a menu with WordPress, you can decide that a menu item links to an external page by adding a Custom Link. (And thank you Press Customizr for the images.)

You can change the target of this link, so that it opens in a new browser tab. For that you need to check an option located below the Navigation label field of the menu item and named “Open link in a new tab“, as illustrated in the following screenshot.

If this option is not visible, it means that it’s not enabled in the menu screen option. Simply follow those steps to activate the option :

  1. Click on the Screen Options link in the top right corner of the menu admin screen.
  1. Check the “Link Target” option : this will reveal the “Open link in a new tab” option.

That’s all folks!

OceanWP Header background image black

Did you try to control this with a function?
And did it stop working recently and is now only showing a blacked out area?
Did you use the hook ocean_page_header_background_image and the function as posted in the OceanWP docs?

Well… Just change your script to give back the image ID instead of the URL:

if ( is_singular( 'post' ) ) {
  // $bg_img = get_stylesheet_directory_uri() . '/img/my-image.jpg';
  $bg_img = 1394;
}

You’re welcome.
Have a nice day!

PS.
Also posted to support hoping maybe OceanWP can fix this, so we can use the image filename/URL again?

WordPress Auto Logout

When you click on the “Remember Me” option on the login page of your WordPress website, it will keep you logged in for 2 weeks. If you don’t, it will keep your login active for 2 days. However, you can extend the auto logout period in WordPress by adding a little code snippet. Keep in mind that it will affect site’s security by keeping user logged in for too long.

function keep_me_logged_in_for_1_year($expirein) {
return 31536000; // one year in seconds
}
add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );

The above code will keep your authentication cookie for a year.

Have a nice day!

WordPress 404 errors

How To Fix Broken Permalinks In WordPress.
WordPress is a powerful CMS. Sometimes a slight tweak can make your website inaccessible. Another common problem that most WordPress users face at some point is WordPress posts returning a 404 Error. In this article we will show you how to fix WordPress posts returning 404 error.

Usually in this scenario a user can access their WordPress admin area, their blog’s main page, but when accessing a single posts they get a 404 Not found error. First of all, don’t panic most of the time your posts are still there and completely safe. This usually happens if your .htaccess file got deleted or something went wrong with the rewrite rules. What you need to do is fix your permalinks settings. There are several sites describing this, below is the summary of what you actually need to do.

UPDATE JULY 2021: “Still haven’t found what I’m looking for”… so I wrote my own htaccess_keeper plugin. It runs on the normal homepage of the website to save the htaccess to a backup file (when changed), and restores it when a zero bytes file has been detected. It also shoots of an e-mail to the admin that it had to jump to the rescue again!
Interested in this plugin? It is for sale, just contact My Brain.

Continue reading WordPress 404 errors