How to mass change the link in WordPress? - php

the thing is, In my WordPress website i have posted some links to some post. and the domain name of the links have been changed and they are so much in an amount in total of 549 posts.the link is like this yourdomain.com/free-access/ and they are in a button. so any suggestions how can i change the domain name.
thanks

The best way to change the domain names in posts is to export and download the database backup. Search and replace the domain name occurrences and save the sql file. Then import the sql file.

You can do a global search and replace with a plugin. There are others but I suggest Better Search and Replace. It's in the WordPress Repository and is free.
Before you make a change like this you should run a full backup, just in case anything goes wrong.
The plugin in question will let you do a dry run, that is you enter your search text and replace text, select the tables you want to search in and then check the box to Run as Dry Run. This will show you where your changes would be made without actually making them, so you're sure you've entered the right search and replace terms.
You can also make changes like this directly on the database tables using SQL but I strongly recommend against it. This tool is much safer.

Related

Query Rewrite in Wordpress - Remove query string in custom pages

I have created a custom page in Wordpress which presents different data based on the query string. So my query string right now looks something like
http://example.com/extcat/?uid=15&src=blog
Now this is not getting picked either by Google's spidering software or by tracking software properly. They are all tracking it as one single page
http://example.com/extcat
without the uid.
What I want is to rewrite the above query in a format like one of these
http://example.com/extcat/uid/15/src/blog
http://example.com/extcat/15/blog
http://example.com/extcat/15/?src=blog
http://example.com/extcat/15/
I don't care which format I use.
I tried using .htaccess and the WordPress api both. Nothing seems to work.
Here is an in-depth article on how to accomplish what you are doing. Basically, you'll need to register your custom query variables so WP can do it's magic using add_rewrite_rule(). It's a long article, but will provide a better answer then I can write. Plus, you'll learn a whole lot!
https://premium.wpmudev.org/blog/building-customized-urls-wordpress/

How to replace bulk href link in mySql database

I have many posts in wordpress. In that post I have links like dev.dev.example.com now I want it to replace with dev.example.com.
I am using following query
UPDATE `dbname`.`wp_posts` SET `post_content`= replace(cast(post_content as varchar(max)), '%dev.dev.example.com%', '') WHERE CONVERT(`post_content` USING utf8) LIKE '%dev.example.com%'
I think it is better to follow wordpress' official guide when moving a wordpress website. http://codex.wordpress.org/Moving_WordPress
Alternatively, as an easy way in your case if you have already done all other steps but stuck in this issue, you can export database to sql file, open in text editor like notepad, use find-and-replace to replace all x.com to y.tom and then import the database. But remember that if domain length is different, you will have some settings lost. It is because wordpress keeps serialized data where length is stored.
Using your way to do via query is not a robust way because some other tables may still have old domain name.

Dynamic hierarchical pages and SEO

Cheers everyone!
Please bear with me, I really did do some research on this, but I couldn't come to a final solution, hence I'm here to hear your opinions.
What I want to build is a small i18n-CMS with dynamic hierarchical pages such as:
domain.tld/en/I/am/a/path
I want to find the least performance intense way that allows me to have beautiful, SEO and human-friendly URLs.
I use a Closure-Table, so two tables in the database, one for the pagenodes and one for the pathtree plus another table for the localised page, that references a certain pagenode (three in total).
My different solutions so far:
Sure I could make an algorithm, that goes through all the different request segments and checks if there is an English "path" under an "a" under an "am" under an "I", but this seems very unwise considering a multitude of page-hits.
Or is it?
Positive: I wouldn't need to save the path anywhere, because it would be calculated. So moving pages around wouldn't need to recalculate the path and save it again.
I could simply save the whole path to the database, as VARCHAR(2000) or something and then just check if there is a page with path "I/am/a/path" in English language and get that one.
This seems to be rather messy.
As I do it now. Currently I add an "ID" at the end of my path. Such as:
domain.tld/en/I/am/a/path.1
So if you enter "domain.tld/en.1" you get forwarded to the one with the right slug. But here again I need to save the slug to the database, for each single page.
Also I would love to get rid of the id (could I do this with mod-rewrite and .htaccess?)
Any more insights on this one? As I'm not a webdeveloper, so I'm not really sure regarding performance.
Kindest regards,
Meren
It seems to me that page request will happen a million times more often than an editor changing a page address. So I would definitely go with the save-to-db option. What you can do is create an extra field in which you save the 'slug' for that page, in combination with .htaccess you can redirect pages from the 'slug' addresses. For example in http://www.fuuu.com/futest-fu , 'futest-fu' is a slug which could be rewritten to an ID number (or anything you would want it to be). Amongst others, Wordpress works this way. Check out this discussion for some insights: http://wordpress.org/support/topic/where-are-the-permalinks-slug-stored-in-the-database

Is it ok to get keywords and description from database?

This isn't really a coding question, but I wanted to ask about what is more efficient and what should I use.
I am making a tutorials website, and each tutorial is brought up onto a page "blog.php" on which all data comes from the database. Now I have two ways I can fill in the meta keywords tag and meta description tag.
I was thinking of making 2 new columns in the blogs table, keywords, and description, and the meta tags would be filled up correspondingly from the database, and the database would get the keywords and description from user input (whover wrote the blog). I know how I would do this but is this efficient? Because I heard search engines have a harder time reading stuff from the database, so I wanted to make sure.
So I can use that OR do you recommend that I use JQuery to get text from the title tag and use that type of stuff? It would be really great because I was hoping to use PHP to make it dynamic, but if I should use Jquery and javascript then please tell which is better!
Thanks!
Search engines never read stuff from the database.
They read only HTML generated by your script.
Storing keywords and description in database is all right.
The only thing you have to change in your setup is database design.
There shouldn't be keywords field in the blog table. Instead of that there should be keywords table and keywords_blog lookup table to link between keywords and tutorials.
Search engines don't read from your database, only you do! What search engines have sometimes struggled with is dyanmic pages, i.e. a page like blog.php where the content changes via the query string, so blog.php?id=1 etc.
What many people do in this situation is use human readable URLs along with rewriting etc so your URLs might be
/blog/what-i-did-today
/blog/why-x-sucks
or similar. This would all be server by blog.php (or index.php or whatever) and then you can easily allow your bloggers to add their own keywords and descriptions via your database.
But do you really need to write your own? There is a ton of software out there that you can just download and install that does this already. Do you need to re-invent the wheel?

How can I create a user-generated page on my website?

For example, say if a user wanted to 'add a place' to my database, how could I create a page almost instantly with that place's name in the domain e.g www.mydomain.com/placename?
I understand it might be a complex solution so if it is too complex to explain can you please push me into the right direction of what I should be researching.
Create functionality to create "pretty urls" in php. Read more about that here: http://www.roscripts.com/Pretty_URLs_-_a_guide_to_URL_rewriting-168.html
Create parsing functionality for the urls, so that it recognizes "/placename" as the page "placename"
Create a database structure for pages with the page id, title, content and the url slug, etc.
Create functionality to fetch the right page from the database according to the matching url slug.
Create functionality to render the retrieved informaton
If I understood you right that's one approach to what you want to do.
I'm assuming you're using Apache. If so, create a rule using mod_rewrite that forwards requests for /place/placename to /place.php?name=placename. Then write the place.php script, which will pull the user page from the database and display it in the appropriate fashion.
That's one way to do it - there are others.
First of all try to understand mod rewrite.
You could "mask: a GET url into a much nicer format.
Start here : http://www.elated.com/articles/mod-rewrite-tutorial-for-absolute-beginners/
Then google on and get yourself familiar with all the possibilities.
After that make sure the GET variable is unique in your database, to be absolutely sure use a unique ID.
Example :
domain.com/PLACEID/PLACENAME/
mod_rewrite could then translate this to your php script into :
domain.com/place.php?VAR=PLACEID&VAR2=PLACENAME
Search the data from the user/place through the PLACEID .
Good luck

Categories