Which is better and faster ? WordPress Queries or SQL Query

Queries ofcourse. It’s faster… But in this case just please delete you wp site and start with something faster… here is my superfast framework for you… <?php /*Your bunny wrote */ I did tests, 0.0000001 runtime vs WP usually 0.7-2.8 Sarcasm off P/S/ This question have no sence since using direct queries and output of … Read more

Defining the same price to all WooCommerce Products

Looks like you are not familiar with WordPress Bulk Edit. Change the Screen Options to show all the products you have (if there are too many this can be slow, and is better to do it following some 100/200 product per page). Select all the products, select Edit in the Bulk Edit dropdown and Apply. … Read more

Copyright: Get first and last date of post type

There was an issue with the code originally posted by kaiser in that it queried for year, month and day distinctly resulting in values representing “the largest month for any date” or the “smallest day for any date” rather than values representing the MAX and MIN dates globally. I altered that original code to query … Read more

What should a WordPress developer know about MySQL? [closed]

Questions like this usually yield a lot of discussions, but let me give it a shot: If you’re talking about SQL queries: If you’re only adding content, managing plugins, themes and WordPress updates, there’s a 99.9% chance that you will never need to write a single line of it. I don’t want to put 100% … Read more

Code to remove authors with no posts connected to them

<?php /** * Plugin Name: Delete Non Authors */ function delete_non_authors() { global $wpdb; $non_authors = $wpdb->get_col( “SELECT DISTINCT $wpdb->users.ID FROM $wpdb->users LEFT JOIN $wpdb->posts ON $wpdb->users.ID = $wpdb->posts.post_author WHERE $wpdb->posts.ID IS NULL” ); foreach ($non_authors as $user_ID) wp_delete_user($user_ID); } register_activation_hook(__FILE__, ‘delete_non_authors’); ?> Drop this in a file, name it something like delete-non-authors.php, upload it … Read more

Connect to MySQL using Windows Authentication

This is just bad security method. Because the only way you can connect to the mysql database is via that pc you use. Where is if you username/pwd, you can move the site to another server, etc. So Windows Authentication is a bad idea, too easy to overcome, and honestly just not that secure. Where … Read more

Many slow queries post_type = ‘attachment’;

This is bug #31071: media / post_mime_type related queries are very slow on larger sites. It should have been fixed for version 4.8 now. You can try it on a test site that is a mirror of your production site. There are some very interesting ideas in that bug discussion. See if you can use … Read more

Paypal Post IPN handeling nightmare

I ended up using kind of a hack. I made a hidden field that was populated with the user ID. I then used this to update metas and what not on a successful IPN and or successful payment. Ie: add_filter(“gform_paypal_post_ipn”, “update_order_status”, 10, 4); function update_order_status($ipn_post, $entry, $config, $cancel){ // if the IPN was canceled, don’t … Read more