WordPress Finally got a REST API
I used Wordpress as the development framework for a mobile application project. Wordpress has a set of XMLPRC api for a very long time. Moreover, the mainstream in Mobile development is to use JSON as the communication format, rather than XML. JSON is smaller and easier to deserialize back to an object. Originally, I planned to use a third party plug-in for REST API and with my own code to build my own version REST API for my mobile application. Today, I checked my WordPress; It got an update for WordPress 4.7. After the updates, I found this version finally got an official REST API. That is great. I can build my code on top of that!
You can check this demo from Wordpress
I upgraded this blog to b2evolution 6.7.7
I have upgraded this blog to b2evolution 6.7.7. I found that is great, the backend is more beautiful and clean too. I found the color scheme too. One thing is good to b2evolution comparing with other blog platforms; that is a very standalone platform which got most functions you need. If you just need it to do blogging, then that is perfect, you do not need to install a single plugin. But the downside, you cannot use it for another purpose. Well, I just need this blog to do blogging. That is good enough. By the way, I installed a responsive skin too. I found that is the best way to get more traffic. Now, Google will downgrade the ranking if any websites are not mobile friendly.
Shortcode in WooCommerce
If you want to have a new custom shortcode in WooCommerce, you can add the codes in wp-content\plug-ins\woocommerce\includes\class-wc-shortcode.php. That will works, however, that is not the best practice. Because if some one updated the woocomerce plug-ins, then your custom code will be overwritten. I suggest you write your plug-in, Then using:
Code
add_shortcode( 'list_products', 'list_products' ); | |
function list_products( $atts ) { | |
.... | |
} |
Then you can have your own shortcode, then you can use global $woocommerce_loop; , that global variable to retrieve the data from woocommerce.
Security Tips for Wordpress
I used a lot of free wordpress template and plug-ins. They are good. But in some situations, especially, the templates and plug-ins are not from wordpress.org. They are from some random websites. You have to be very careful. You have to check them very carefully. I will do a code review for that.
There is a common technique, they will use. The page will detect the user agent string. If you use a normal browser, they will deliver a normal content. When the search indexing engine visit them, they will deliver the spammer content. To check that, you can use the fetch as google in Webmaster tools for checking. If you are a power user, you can use some browser plug-ins to change your agent user agent string to be a indexing engine.
The number of posts per pages in Wordpress
No doubts, you can modify the wordpress functions library to control the number of posts in archive page and category page. That may be hard for you. There is a plug-in to do that. This is Custom Post Limit. Although the plug-in has not been updated for more two years, I tested that still works with the latest version of Wordpress. Moreover, you just need to fill in the number of posts per page you want in the form. Then that will work!