36 votes

Delete all posts of a custom post type—efficiently

You can delete all post via $wpdb DELETE FROM wp_posts WHERE post_type='post_type'; DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT id FROM wp_posts); DELETE FROM wp_term_relationships WHERE ...
user avatar
22 votes

get_option() vs get_theme_mod(): Why is one slower?

The answer that yes, the theme_mod functions will be slower, but not significantly, and the benefits outweigh the differences. Theme mods are stored as options. So, in essence, the theme_mod ...
user avatar
  • 32.1k
18 votes

Any reason why wp_cache_set not to work?

The wp_cache_*() functions are non-persistent caches which means that they only last during the current page request. This would be beneficial if you're requesting the same information multiple times ...
user avatar
  • 19.7k
14 votes

Wordpress so slow to load on MAMP

Go to wp-config.php, find the line below: define('DB_HOST', 'localhost:8889'); And change it to: define('DB_HOST', '127.0.0.1:8889'); Works like a charm!
user avatar
11 votes
Accepted

How can I debug the TTFB in WP?

Meanwhile, I found some plugins and tools that can help with this: Query Monitor Laps Debug Bar with some add-ons(Slow Actions, Rewrite Rules, etc.) If you really wanna go deep, try using Webgrind. ...
user avatar
  • 311
11 votes
Accepted

How many posts can I have in a WordPress website?

2,000,000,000,000 WordPress posts, is it possible? Simple answer, Yes. The days of 2GB size limit on file systems are gone. Now, you can literally have unlimited entries on almost everywhere if your ...
user avatar
  • 14.7k
10 votes

Delete all posts of a custom post type—efficiently

This can now be done with the WordPress CLI using wp post delete. Once the CLI is installed, the following terminal command (while in your site's root directory) will delete all posts of type ...
user avatar
  • 201
9 votes

What's the difference between wp_insert_user() and wp_create_user()

As per Codex The wp_create_user function allows you to insert a new user into the WordPress database. It uses the $wpdb class to escape the variable values, preparing it for insertion into the ...
user avatar
  • 409
9 votes

Delete all posts of a custom post type—efficiently

You can delete all posts of a custom post type in various methods but here I am gonna show you how to do this without using SQL query. Here, for example, our post type is product $allposts= get_posts(...
user avatar
7 votes
Accepted

Is it true $wpdb->get_results is faster than WP_Query in most cases?

How can I prepare() my wpdb query? I tried but couldn't manage because of the second parameter. The prepare() works is explained in Codex, you need to have a query with placeholders and additional ...
user avatar
  • 44.8k
7 votes
Accepted

Is security a problem in Wordpress?

In a general sense, any well maintained platform can be used to to create a website with good security. It has to be noted that you will never build a website which is completely secured against ...
user avatar
7 votes
Accepted

WordPress tips for speed and performance

I work with several large WordPress sites, news sites specifically, that have thousands of posts and thousands of visitors (300k/day). With the stuff below, and a well coded theme, with well written ...
user avatar
6 votes
Accepted

Multiple plugins vs combined one

If it's exactly the same code, then no - it shouldn't cause any performance changes... Why? Because loading a plugin is pretty easy (hence quick) process. It all happens in wp-settings.php and this ...
user avatar
6 votes

Is it useful to turn on MySQL query cache for performance

General speaking yes for read-only applications (until MySQL 5.7, it's deprecated since version 8.0), it enables equal SELECTs to return data extremely fast if identical calls are already stored in ...
user avatar
5 votes
Accepted

Nginx FastCGI_Cache Vs PHP Caching

Nginx is really good at concurrency (PHP not so much) so you should try a bit more than 180 requests per second. Maybe 500, or 1000 depending on your server resources and network throughput. The ...
user avatar
  • 2,523
5 votes
Accepted

Wordpress shortcodes & performance

You need to look at this from a couple of perspectives and then you have to weigh the odds against each other In general, shortcodes will be slower (we are talking milliseconds here) as they need to ...
user avatar
5 votes

How many posts can I have in a WordPress website?

Adding a little Rick Hellewell answer. Creating some custom PHP/MySQL code to do it is a different thing than using Wordpress for it - the main difference is the table structure, which can be much ...
user avatar
  • 1,018
5 votes

Is 30 posts/sec considered slow for wp_delete_post?

Speed factor of any function that deals with content such as wp_insert_post() or wp_delete_post() highly depends on the situation and the content that it's dealing with. Let's make a simple example. ...
user avatar
  • 14.7k
5 votes
Accepted

Do multiple revisions really slow down WordPress?

Having 2 revisions or 100,000 will not change front end performance in a default plugin-less WordPress setup However plugin and theme authors who do not query the database correctly, could end up ...
user avatar
  • 3,227
5 votes
Accepted

wp_redirection_404 table has grown to 7GB

That table is from the redirection plugin, and isn't a part of WordPress Core. Deleting it should have no ill effects as long as you disable the plugin too. If you wish to continue using that plugin ...
user avatar
  • 53.3k
5 votes

wp_redirection_404 table has grown to 7GB

This is a LOG table. It logs 404 errors - requests that Redirection could not resolve. The proper way to shrink the table is: change the setting "time to keep logs for" to something shorter than "...
user avatar
  • 151
5 votes
Accepted

Sample -- test -- data for large WordPress install

Few built-in wp-cli generate commands from the docs: # Generate posts with fetched content. # See https://developer.wordpress.org/cli/commands/post/generate/ $ curl -N http://loripsum.net/api/5 | wp ...
user avatar
  • 64.4k
4 votes
Accepted

What effect does the_content filter have on performance?

The difference would be negligible. The the_content filter is fired regardless of whether you use it or not because WordPress uses it for other things. So the only thing that would be performance ...
user avatar
  • 4,420
4 votes
Accepted

Disable slow media queries?

Solution for WordPress versions >= 4.7.4 (4.8) Ticket #31071 introduces patches with new filters to override three possible slow media queries, in the wp_enqueue_media() function: ...
user avatar
  • 64.4k
4 votes
Accepted

Improving the perfomance of a plugin action

Your original piece of code (the code from the previous question) did need some performance boost in the context it was given. As for the updated code, you will need to remove the fields parameter as ...
user avatar
4 votes

Is it better to assign functions like get_the_id() to a variable if it's used multiple times?

Yes, it is always better to keep the result of a function call in a private variable. But the reason is not performance. Reliability In your example, you are calling a function that internally ...
user avatar
  • 105k
4 votes
Accepted

Conditionally loading JavaScript based on the Advanced Custom Fields in the post

ACF has finegrained filters for fields when they get loaded. add_action( 'wp_enqueue_scripts', 'register_my_scripts', 5 ); function register_my_scripts() { wp_register_script( 'my-script', 'path-...
user avatar
  • 1,771
4 votes

WordPress website loads but is not displayed until page scrolled

I have visited your site in several browsers, including Chrome, and everything is working fine. The sole fact that you only experience the problem only in chrome, already means that this question is ...
user avatar
  • 13.8k
4 votes

Uploading images to Media Library fails with Memory Exhausted

There is already a built-in function created just for that purpose. You don't need to write walls of codes to uploads images from your disk. You can use media_sideload_image instead. This function ...
user avatar
  • 14.7k
4 votes
Accepted

wp_register_script multiple identifiers?

To have the JavaScript Libraries not to load since you already created a bundle of them, do the following: Asumming the following, usual enqueue: function the_js() { wp_enqueue_script('bundle_js'...
user avatar
  • 3,571

Only top scored, non community-wiki answers of a minimum length are eligible