How to replace multiple urls to one specific url at once? - wordpress

In wordpress database We have these thumbs as url links:
1st example:
http://thumb-v.xhcdn.com/t/170/1_6933170.jpg
2nd example:
https://thumb-v.xhcdn.com/t/325/200/3_8168325.jpg
Others are similar. There are over 2000+ urls are exist in the database like above. However the entire database have 15000 urls different than these urls. So I don't want to change all of them just the above structured ones.
I'd like to change/replace these multiple urls with one specific url like this:
http://example.com/lockedthumb.jpg
How to do this? By excel? Or is there any useful wordpress plugin?
As you can see multiple & different urls are starting with this: http://thumb-v.xhcdn.com/t/ or https version. But the rest of it has different numbered folders and jpg filenames.

You can try this in SQL :
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://thumb-v.xhcdn.com/t/170/1_6933170.jpg', 'http://example.com/lockedthumb.jpg');
You have to edit the table name and the field where are saved the data you search.
Best regards

Related

How Do I List Wordpress Posts with ID Less Than Some Number with WP-CLI

The following WP-CLI command works great for getting all posts in a specific category, but I need to restrict it further to just those with an ID number less than a specific number. This is because I just exported a bunch of posts below a specific ID number and now need to remove them from the original site.
wp post list --cat=34 --format=ids
What must I add to the above so that the list only includes posts with ID<16163
I thought --post__in might do the trick but this only seems to list specific posts if you list their ID numbers separated by a comma. The description from Wordpress looks like it takes a range but it seems like a specific list.

Where are the Yoast SEO titles and descriptions stored?

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.

Wordpress and plugins (inventor) where posts table is defined

I need to make some work with wordpress 4.9. The table prefix is defined as abc_ and some posts is exists in table abc_posts. But also tables abc_2_posts and abc_3_posts is exists. Site catalog is actually rendered from abc_2_posts. Where this is configured?
This is because you are using a multisite installation. Every site in the network will have a unique id assigned to it. Looking at the table name abc_2_posts the number 2 tells you that this table is used by the site with id 2.

In WordPress, should it be possible change a word in all pages of a site in once time?

I know it sounds crazy, but as asked above, i have lots of pages with the word "Vocal" between and tags and i would like to change this word to "Voices". Make it one page by one would be very tiring and take a lot of time. If it is not possible, "Vocal" should remain as it is. Thanks for any help!
My suggestion would be to export your WordPress database to a .sql file.
(possibly you would only need to export your wp_posts table, if you only really need to replace it in the page/post content and nowhere else in your entire site)
Then open it in a text editor of your choosing and do a find replace.
Search for %Vocal%
Notice the the % symbol, just replace them with a blank space.
Then do a replace with %Voices%.
After you are done save the .sql file and import it to your database.
Of course keep an original backup of the file, in case anything goes wrong :)
First backup your database! Then run the SQL command
update wp_posts set post_content = replace( post_content, 'Vocal', 'Voices' );
Try https://wordpress.org/plugins/search-regex/ It hasn't been updated in a while, but it works. You can find/replace with either grep or plain text in post content, post meta, etc. No reason to use PHPMyAdmin or run database queries. Backup your database first.

Filter to Group URL on Visitors Flow

I have found a similar question earlier here:
Google Analytics Visitors Flow: grouping URLs?
However I'm confused because people suggest different way to write the Replace String, and either way I try it am not able to make it work.
So I have a ecommerce site with hundreds of different pages. The different parts of the website is:
http://example.com/sv/ (Root)
http://example.com/sv/category/1-name/
http://example.com/sv/product/1-name/
http://example.com/sv/designer-tool/1-name/
http://example.com/sv/checkout/
When I go to the visitors flow. I want to see the amount of people that go from example Root to Category, and from Category to Product, and from Product to Designer Tool, and from Designer Tool to Checkout. However now when I have so many different pages it becomes very difficult to follow the visitors flow, because the product pages are for example not grouped together.
So instead of above. I would like to remove the 1-name/ part in the end. And only see /sv/category/, /sv/product/, /sv/designer-tool/.
In the earlier post I understand you can use an advanced filter to do this. I have set the following settings:
Type: Search & Replace
Field: Request URI
Search String: ^/(category|product|designer-tool)(/\d*)(.*)
Replace String: /$A1$A3
I guess that my search string and my replace string is wrong. Any ideas?
EDIT: I updated my filter to the following:
Search String: ^/sv/(category|product|designer-tool)(/\d*)(.*)$
Replace String: /sv/\1/
Still testing and unsure if it's the correct way to set it up.
I was able to solve this by the Search String and the Replace String in my edit above.
So basically what I did was:
Create a secondary view/profile for your site. If you apply your filter to your one and only view/profile that means that you won't be able to see any detailed data about specific pages, because the filter removes/filter that.
Add an Advanced Filter with the following settings:
Type: Search & Replace
Field: Request URI
Search String: ^/sv/(category|product|designer-tool)(/\d*)(.*)$
Replace String: /sv/\1/
You need to wait 24h after creating your new profile/view before you can see any data in it.
So my confusion was regarding the Search and Replace String. The Search String is an regular expression for matching everything after your .tld. So for example http://www.example.com/sv/mypage/1-post/, the Search String will only search within /sv/mypage/1-post/.
The Replace String is what it should replace the whole Search String with. So in my case, I matched all URL's that had /sv/category/1-string/. I wanted only to keep the "category" part, so I replaced the whole string with /sv/category/ by inputting Replace String /sv/\1/
/sv/ means just what it says. \1 means that it should take the value of the first () of my Search String (In this case "category"). The ending / is just an ending slash.
All in all, it means that any URLs that looked like http://example.com/sv/category/1-string/ was changed to http://example.com/sv/category/. Meaning that I can now see data for all my categories as a group, instead of individual pages.

Resources