30

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 object_id NOT IN (SELECT id FROM wp_posts) or use this query replace it with {{your CPT}} with your Custom Post Type DELETE a,b,c FROM wp_posts a LEFT ...


20

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 functions are wrappers around the options functions. First, understand that theme_mod settings are stored as an array in a single option, keyed to the specific theme ...


16

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 during page load. For example, if you're showing recent posts in the header, content section, and sidebar ( calling the same code 3 times to retrieve recent ...


13

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!


11

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. Not the most friendly tool, but it'll do the job. Be aware that some of this tools will also have an impact on performance.


10

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( array('post_type'=>'product','numberposts'=>-1) ); foreach ($allposts as $eachpost) { wp_delete_post( $eachpost->ID, true ); } See full tutorial ...


10

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 hardware can support it. So I'm gonna change the question into this: 2,000,000 WordPress posts, Should I have it? To decide whether WordPress is a good choice ...


8

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 database. Then the PHP compact() function is used to create an array with these values. To create a user with additional parameters, use wp_insert_user(). ...


8

There are a couple of reasons why this generates more queries than you expect. First, ACF stores fields as two distinct pieces of data - one part contains info about the field, what settings you selected, how to format output, etc., and the other part contains the actual value assigned to that field. So right there you have an extra query per field- the ...


7

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 arguments to replace that placeholders. If you have no placeholders (so no variable parts in the query) then you can use esc_sql to avoid SQL injections, but ...


7

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 hacking and spamming, no matter which platform you use and no matter what genius or pro you are. Hackers evolve faster that the security of a specific piece of code ...


7

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 queries, we're loading in 2.5s with 7 ad blocks from AdSense and RevContent. Do you have a CDN? I highly recommend a CDN if you don't have one. Depending on ...


5

This type of question is open ended to answer because it depends on many variables. The typical memory usage of bare WP usually starts at 15MB and scales up. What you can do is turn on debugging and install the Debug Bar plugin and it will show you the amount of memory you're using. In wp-config.php set define( 'WP_DEBUG', true ); Another plugin which ...


5

Pods allows you to create meta-based or table-based content types. Meta-based work as normal WP post types do. You can also extend WP objects like Comments, Users, Media, and Taxonomies to add custom fields to those. If you choose to use table-based Pods, it creates a table with the ID field and only the custom fields that you define yourself. There are ...


5

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 mycustomtype: wp post delete $(wp post list --post_type='mycustomtype' --format=ids) No raw SQL (*shudder*), no worrying about timeouts, and it's fast. For example, I ...


5

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 fastcgi_cache is served directly from ram. Wp-super-cache uses php to read a static file from the SSD so I see why it should be faster so why isn't it? It ...


5

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 more efficient when designed for a specific purpose. Wordpress is design to keep all data in mainly one or two tables so getting them out usually needs a lot of ...


5

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 accidentally searching/querying revisions, which could have some performance issues Here’s a snippet on it revisions take up space in your WordPress database. ...


5

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 though, I recommend using the plugin authors support at https://wordpress.org/support/plugin/redirection/


5

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 is the code: // Load active plugins. foreach ( wp_get_active_and_valid_plugins() as $plugin ) { wp_register_plugin_realpath( $plugin ); include_once( $...


5

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 cache. You should consider that: Only exact same clauses can benefit from the cache engine (no spaces, no comments, no actual differences in WHERE expressions); ...


4

The Transient API saves data inside the database, which isn't as effective as APC, but a similar workflow as used for transients can be used for APC. It is important to check if APC is available and active, so its functions are usable. Because this isn't always the case, it is to consider to add a alternative to APC via Transient API and combine those two ...


4

The number of sites is unrelated to the amount of memory required. The amount of required memory is (if you are using Apache) the amount of memory required to serve the most memory intensive page * the number of requests you want to serve simultaneously Both numbers vary based on the way you set your server and the themes and plugins you use.


4

The actual RAM you need depends on many factors: plugins theme installed extensions (server and PHP) the current operation (editing images needs the most) translation, some translation files are really heavy In a multisite, some resources are shared, the server setup for example is not duplicated each time you create a new site. You can save some ...


4

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 related would be the complexity of your filter function. But since you'd probably be doing the same level of complexity in a template or in the filter function, ...


4

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: media_library_show_audio_playlist (@param bool|null) From the inline doc: Whether to show the button, or null to decide based on whether any audio files exist in the media ...


4

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 you need to get the full post object and not just the ID. To optimize code in queries, you will need to know before hand what you will need from the post. I ...


4

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 be parsed and processed by the shortcode handler. USAGE: [my_shortcode] in post editor Shortcodes in general are quite useful and usally outweigh the fact ...


4

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 accesses a global variable ($post). A global variable can be overwritten any time, so you might end up with two different post IDs, because some other code changed ...


4

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-to/my-script.js', array(), 'version', true ); } add_filter('acf/load_field/name=my_field_name', 'load_field_my_field_name'); function load_field_my_field_name(...


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