Skip to content

Instantly share code, notes, and snippets.

@thagxt
thagxt / Add a custom url in the Wordprss Admin bar.php
Last active September 18, 2022 20:42
Add a custom url in the Wordprss Admin bar!
<?php // copy & paste the code below in your functions.php file, change the title and href and save it.
function add_link_to_adminbar($wp_admin_bar){
$args = array(
'id' => 'custom-link',
'title' => 'Custom Button Title',
'href' => 'http://example.org/',
'meta' => array(
'class' => 'custom-link-class'
@thagxt
thagxt / functions.php
Created January 31, 2015 15:51
[WordPress] Change the wp-login.php?action=lostpassword to /lost-password/
/*
* code below goes in your functions.php theme file.
*/
// changing the wp-login.php?action=lostpassword to /lost-password/
function custom_lost_password_page() {
return home_url('/lost-password/');
}
add_filter('lostpassword_url', 'custom_lost_password_page');
@mikaelz
mikaelz / delete-all-woocommerce-products.php
Last active April 30, 2024 06:07
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
@mikaelz
mikaelz / remove-all-product-categories-tags.php
Created January 27, 2016 11:37
Remove all WooCommerce product categories and tags
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE a,c FROM wp_terms AS a
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id
LEFT JOIN wp_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id
WHERE c.taxonomy = 'product_tag'");
$wpdb->query("DELETE a,c FROM wp_terms AS a
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id