I have created CPT using CPT UI plugin and suddenly I lost all the important data. I don't have any backup and I need it backup. Is there any I can get it backup? I have SQL backup of last week.
Moreover I am seeing Count on CPT categories but they are showing Empty on main CPT page. for example CPT:
Animals --> showing (0) posts
Animal Categories is showing 100 counts that means It has data but something has hide it. I remember I updated Permalinks but I don't remember the previous settings
use this sqlQuery in your SQL Database (phpMyadmin or ...) and you will get a list of your custom post type posts with their info:
SELECT *
FROM {table prefix}_posts
WHERE post_type = 'your_custom_post_type_name'
AND post_status = 'publish'
your {table prefix} can be wp or some thing else if you've change it on wp setup step you can check it in your Database or wp-config.php file in your wp root.
you can replace * in query with whatever field name you want for example:
post_content, post_title, post_excerpt
to only get fields that you need.
Related
I am working on a Woocoomerce site with many categories.
I have to add some text at the end of the categories (suffix) slug. Like "klm".
How to change product category slug in bulk in Woocommerce?
For example,
Furniture > Kitchen Furniture
The permalink for the category is as follows:
"kitchen-furniture"
What I want to do is add a new text (suffix) to the end of all (main category or subcategories).
For example,
"kitchen-furniture-klm"
Yes, this can be done from wp-admin>Products>Categories. However, as I said at the beginning, there are many categories.
There are 22 pages of entries for categories on Stackoverflow. I've looked at almost all of them. However, I couldn't find what I was looking for. I would appreciate if someone could guide me where to start.
Note: Please take database backup before execute following update query
You can do this in database, using following query
UPDATE wp_terms SET slug = CONCAT(slug, '-klm') WHERE term_id IN(SELECT term_id FROM wp_term_taxonomy WHERE taxonomy = 'product_cat')
I'm managing a small directory website and I have set some generic titles and descriptions for my pages with Yoast SEO Plugin.
I'd like to duplicate them to every entry/page directly via the MySQL database. However, I cannot find it in the DB.
I didn't find it in wp_postmeta, wp_posts or wp_yoast_seo_meta.
That's why I ask: where does Yoast (v. 7.8) store the SEO informations that a user set?
So after some time, I figured out that the best way to find out where this data where stored was to dump the DB and look in that dump:
mysqldump -u wordpress --no-create-info --extended-insert=FALSE wordpress -p > dumpydump.sql
cat dumpydump.sql | grep "What you're looking for"
What you'll find is an row called wpseo_taxonomy_meta in table wp_options which contains every taxonomy SEO texts. It is saved as a PHP serialised value.
Be careful though that this is just for the SEO texts of the Taxonomies (e.g. Location, Feature, Category...). It doesn't apply to the SEO descriptions and titles of the posts themselves (these are stored in wp_postmeta with at least one row per post).
Yoast SEO Save Description and Keywords in wp_yoast_indexable Table. Where you can see column name description and keywords
just use this code, you'll get an array of all settings that Yeast SEO show under "Search Appearance" page. Including title, descriptions and all other settings.
$wpseo_search =get_option( 'wpseo_titles', $default = false );
Update your required field and save using the update_option() function of WordPress.
You can use this (for categories):
$wpseo_options = get_option( 'wpseo_taxonomy_meta');
$wpseo_options['category'][<the_category_id>]['wpseo_title'] = '... my title';
$wpseo_options['category'][<the_category_id>]['wpseo_desc'] = '... my description';
update_option('wpseo_taxonomy_meta', $wpseo_options, true);
It should work. Also, you should check the wp_yoast_indexable table for correct recordings.
I have a strange situation where I need to move current taxonomies from one post type to a new one in Wordpress.
If I change the taxonomy post type within the functions I am losing all categories and relationships.
You should change the ID's in the database, take a long look at the phpmyadmin
wp_term_taxonomy
wp_terms
wp_term_relationships
In the terms table you will find the id of the old and new taxamonies
in term_taxonomy replace all old term_id with the new.
SQL:
UPDATE `wp_term_relationships` SET `term_id` = REPLACE(`term_id`, /*old id*/, /*new id*/);
Do make a backup before you start.
Source: Here
While #uvishere is right with his answer when you have a lot of categories to deal with that process can be a real headache.
What I have done is I created the taxonomies keeping their previous names under the new post types. Wordpress however will not add the new categories to these new post types once I uploaded the code but I then removed the old taxonomies from the code and all categories shifted under the new post type keeping the id's relationships ecc.. which was great and fast!
Now all I had to do is move the posts from one post type to the other and I have done so using the Post Type Switcher plugin
Currently our site's videos are posted as custom post type. We have totally changed the theme and added so many new features. For our new site we are trying to change videos to category. (Custom post type to normal categories). Is this possible. I have exported the custom post type as XML file, but I don't know how to change it to categories.
Finally an answer. Before I start These are the conditions I'm using.
The Custom posttype (called video) need to be merged into the default post
Video's has it own custom categories, who needs to be merged into the default categories
All Video's need to get a category video, the old categories need to be children of the newly created video category.
Step Zero: BACKUP my sql BACKUP
First create a the video category in the default posttype. Note it's ID (it is found in the category edit page in the url under tag_ID. I'm assuming ID 4 in my examples
Second we assign this category to the video posttype with the following Sql:
INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`)
SELECT `ID`, '4' FROM `wp_posts` WHERE `post_type` = 'video';
Next we assign the existing custom categories as children. You need the video category slug, found on the custom-category page agian in the url with taxonomy.
UPDATE `wp_term_taxonomy` SET `parent` = 4, `taxonomy` = 'category' WHERE `taxonomy` = 'VIDEO CATEGORYSLUG';
The last step is assigning the normal posttype to the custom posttype.
UPDATE `wp_posts` SET `post_type` = 'post' WHERE `post_type` = 'video';
Now it should be done and everything should be merged. So TEST TEST TEST.
After that the code making the posttype can be disabled.
This should work, if you have questions just ask.
How can one reset the number of post views in order to remove a specific page from appearing in the "Popular" pages Wordpress widget?
Late to the party, I know, but I needed to figure this out today, which I did. So in case anyone else needs to know (for reference, I'm running WordPress version 3.3.1):
Page views are stored in the wp_postmeta table with a meta_key of post_views_count. Here's the query I used to find the views of a single post:
SELECT * FROM 'wp_postmeta' WHERE 'meta_key' = 'post_views_count' AND 'post_id' = 1234
The query returned 2 results. I'm not sure why, but setting the meta_value of both to zero did the job for me.