Category Archives: wordpress

What contributing to WordPress taught me

Now I know why every Automattician should start with happiness engineering. After helping out on WP.org forums, #wordpress IRC channel (now Slack) and contributing to WordPress Core they better understand the real user needs/problems. This problem solving hugely helped me with learning. … Continue reading

Posted in wordpress | Tagged , | Leave a comment

SQL to get WooCommerce product categories (terms)

For an import script I needed to get WooCommerce product categories so I ended up looking the generated query in /var/log/mysql/query.log for get_the_terms($postID, ‘taxonomy_name’) I ended up using the following SQL query to get product categories: SELECT t.*, tt.* FROM … Continue reading

Posted in mysql, sql, Uncategorized, woocommerce, wordpress | Tagged , , , , | Leave a comment

Multiple database connection in WordPress

For import from one WordPress install to another multiple database connection comes handy. The trick is instantiating a new wpdb with different database credentials.

Posted in wordpress | Tagged , | Leave a comment

Change locale for WooCommerce email

To change WooCommerce email language you need to change the locale after order submit. Using $_GET might be dirty, but works 🙂

Posted in Uncategorized, woocommerce, wordpress | Tagged , , , , | Leave a comment

Debugging duplicate query exec in WordPress

During debugging a plugin malfunction I had duplicate option update SQL queries and after som thinking I came up with the following debug line to catch the trace of duplicate function call: error_log(var_export(debug_backtrace(), true)); I placed it above the return … Continue reading

Posted in Uncategorized, wordpress | Tagged | Leave a comment

Mail sending via SMTP for WordPress

I was looking for some really simple SMTP solution for WordPress, only some code to send emails via SMTP. Without a plugin for localhost usage. Came up with the following script in wp-content/mu-plugins/smtp.php <?php add_action(‘phpmailer_init’, ‘custom_phpmailer_init’); function custom_phpmailer_init($phpmailer) { $phpmailer->IsSMTP(); … Continue reading

Posted in Uncategorized, wordpress | Tagged , | Leave a comment

WordPress custom search for custom post type

After creating a custom post type for an Inventory plugin the client needed also customized search for the columns. First the pre_get_posts looked as a good candidate for hooking, but ended up with filtering via posts_clauses_request add_filter(‘posts_clauses_request’, ‘customSearchClause’); function customSearchClause($query) { global … Continue reading

Posted in Uncategorized, wordpress | Tagged , , | Leave a comment