Category: "WordPress Tips"
UTF-8 Slug Issue on WordPress
In the past, my hosting server supports UTF-8 URL, I can use the chinese name as Slug in wordpress. In the past few days, there is a server upgrade, then UTF-8 does not support anymore. In the past, because I am lazy, blogging in my top priority, I left the chinese name in URL. I know that is not good for SEO. Also, it made all post links are not working anymore.
I found only way is to reset all post slugs with a random number. I know that affects SEO, it made all post links in search engine in not working.
At the end I ran this sql to reset all old posts,
update set wp_posts
set post_name = floor(RAND()*10)+15
where post_name like '%\%%'
That is a bad solution, but that is the best solution I had now. Now, I manually write 301 Direct for all popular posts I have aware to the new url.
The Database Object in WordPress
You can access the database via WordPress. You can use any raw SQL too. That is quite easy. You only need to call a global object;
For the raw SQL, you can use query method:
SET post_parent = 10
WHERE ID = 15
For get the record set,
$drafts = $wpdb->get_results(
WHERE post_status = 'draft'
AND post_author =1
There are insert, update and delete method too.
Please read WordPress development documentation for the further information