Skip to content

Instantly share code, notes, and snippets.

Nikita n1k1c4

  • Russia, Ekaterinburg
Block or report user

Report or block n1k1c4

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View wc_delete_all_orphaned_postmeta.sql
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL
View wc_delete_all_attributes.sql
DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%');
DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%';
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);
View wc_delete_all_products.sql
DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_posts WHERE post_type IN ('product','product_variation');
View wc_delete_all_tags.sql
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';
View wc_delete_all_categories.sql
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_cat'
@n1k1c4
n1k1c4 / wp_replace_url.sql
Created Jul 11, 2017
WordPress - Replace URL in database (SQL query)
View wp_replace_url.sql
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://old', 'http://new') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://old', 'http://new');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://old','http://new');
UPDATE wp_posts SET guid = REPLACE (guid, 'http://old', 'http://new');
UPDATE wp_comments SET comment_content = REPLACE (comment_content, 'http://old', 'http://new');
UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url, 'http://old', 'http://new');
@n1k1c4
n1k1c4 / show_the_number_of_queries_and_time.php
Created Jul 11, 2017
WordPress - Show the number of queries and time
View show_the_number_of_queries_and_time.php
<pre><?php echo $wpdb->num_queries; ?>q, <?php timer_stop(1); ?>s</pre>
@n1k1c4
n1k1c4 / show_template_file_name.php
Last active Jul 31, 2017
WordPress - Show template file name
View show_template_file_name.php
<?php if (current_user_can('administrator')) : ?>
<div class="for-develop" style="position: fixed; min-width: 15%; height: 32px; background-color: #E91E63; top: 0; left: 750px; z-index: 100000; color: #fff; text-align: center; line-height: 1.8;">
<?php global $template; echo basename($template); ?>
</div><!-- /.for-develop -->
<?php endif; ?>
You can’t perform that action at this time.