There are posts which inserted multiple time with post_name like "icegram-2", "icegram-3", "icegram-4" along with "icegram".
Now, I want to remove posts with post_name "icegram-2", "icegram-3".
It's an example. There are more posts like this. I want to delete all such duplicate posts.
Is it possible with mysql query?
You could use the following plugin:-
https://en-gb.wordpress.org/plugins/delete-duplicate-posts/
Maybe have a look at How to delete Duplicate posts in WordPress
If I find anything else I will update my answer.
Delete Duplicate Posts plugin can helpful for you
Related
I've created a demo website where I want every post to have the same content. I've created 50 posts through a random post generator plugin. I have edited one post's content. Now is there a way to copy the content and paste to all 49 other posts?
E.g. I used this query to duplicate the excerpt.
$wpdb->query( "UPDATE wp_posts SET post_excerpt='This is an excerpt for the post' " );
Looking for a similar query. Please guide.
I have a website with coupons and a large database. In wp_postmeta most of my posts have a store_id, because I use the plugin Yoast SEO and it sets the meta_key and the meta_value. Not all of my coupons have a store_id in the wp_postmeta, like the older coupons or some of them who was copied from the old ones, or who came automatically through API.
If I update every coupon and re-click the store part, the post gets the store_id written in the table wp_postmeta. But I have more than 50 000 coupons... I need the store_id set for every coupon I have, for other tasks I need to do.
Is there an easier way how to do this, without manually updating every coupon?
First, please make a backup.
If I understand correctly, yoiu need to change every row in the wp_postmeta table to set the store_id to the same value. If I've misunderstood in some way, that is, if you need to set a different value for some rows or if you don't want to over-write existing data, you should stop reading here. I don't know anything about Yoast SEO and only know as much as I've perceived from your post here.
But changing a single column for all rows is easy. You need an SQL statement something like this:
UPDATE `wp_postmeta` SET `store_id`=1
That will change the store_id of every row in wp_postmeta to 1.
Since you've tagged phpMyAdmin, presumably you're using that as your interface. Just click the SQL tab once you're in your WordPress database to enter the text of the query directly there.
Is there a simple way to count how often a meta_key exists in the database like wordpress do with:
$n_post = wp_count_posts();
Anybody can help?
Check last rows in a table which are associated with specific user/post, Take that ID and count meta_keys on the bases of that ID, Hope it will return all the meta_keys...
I have 20 thousands plus posts and all posts have title started with
Watch etc etc...
I want to remove watch from all post title please give the solution how i can do this. Is there any filter which can do that.
Run this query in your phpmyadmin
UPDATE wp_posts
SET post_title = REPLACE(post_title, ' Watch ', '');
Where
wp_posts is your post table name
The simplest solution would be to use the following plugin and search and replace given string in the post_title column in the database.
Does anyone know how to display 3 previous posts on article page? Let's say I'm in article post page and would like to display previous 3 posts images (basing on the post I'm currently reading) below it's content, but not next posts images. I was trying to do this with setting up the offset in the db query but with no luck. Can someone please help me with this one? I would greatly appreciate any help or at least pointing me in the right direction.
That shouldn't be too hard, if you use an id field with auto increment values, you could do something like this:
SELECT id, name FROM articles WHERE id < {current_id} ORDER BY id DESC LIMIT 3;
Obviously, replace {current_id} with the id of the article you're currently reading.
After displaying the specific post do a new WP_Query to retrieve the 3 posts previous to the publication date of the displayed post. This documentation page describes how to query for posts with a relative date (e.g. the example Return posts from the last 30 days). Base the query on the publication time of the displayed post.
The example includes a way to supply a WHERE clause to the query, with add_filter(). I'm not sure, but I think you need to call remove_filter after doing the query, or that filter might be applied to other queries also.