I wish to change the format title in header in one of my wordpress websites. I know I can define a custom function to change that. I tried that, that is not working my template. Finally, I found a cleanest and easiest way to do, without writing a single line of code. That is to install Yoast SEO plug-in. This plug-in can allow the user to define page title in header for each page and post. That is very flexible. Moreover, it has a lot of placeholder too, such as site title, page title and post title.
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.
I built a wordpress plug-in. The plug-in is working fine in a server, but another server returned an error about '[. I compared the two servers. Their php is different. The problematic server got old version of php which is php .5.3. Then I read the php specification. The Square Bracket array declaration which used in C# and Java is only available on Php >=5.4. So I have to change square brackets to array(). Then it works fine.
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
Although WordPress got its own JSON API, you still have your own JSON API for your own plugin and serialize your own data. That is not a problem. WordPress library got a function to serialize any objects to JSON Format. That is very easy. You can use this function in any parts of your plug-in.