If you use the Amazon Product In A Post Plugin on WordPress you might have either not upgraded yet or decided to not upgrade because the shortcode syntax has changed. You can get around not upgrading by updating the WordPress post content immediately after you upgrade the Amazon Product In A Post Plugin. Below I describe the version that I upgraded and the MySQL syntax used to update the shortcode syntax to display Amazon products in WP posts.
Amazon Product In A Post Plugin: WordPress Plugin Site
Current Version: 2.0.2
Latest Version: 3.5.2
The Amazon Product In A Post Plugin has been a great WordPress plugin for me not only in an attempt to generate money to pay for hosting for this site but also to provide resources in the form of books that can be used for reference or to expand ones horizons. The latest version is 3.5.2 and provides tons of extra functionality however the shortcode syntax changed so that extra functionality could be provided. This could be a pain for existing sites if your knowledge of SQL syntax is limited though updating your current content is easy following the below directions. Follow the steps below to upgrade the Amazon Product In A Post Plugin on your WordPress installation.
Upgrade AmazonProduct In A Post Plugin From 2.X to 3.X:
- Backup WordPress MySQL Database: First you will want to use mysqldump to backup your WordPress database so it can be restored if you run into any issues. Use the below syntax to backup the WordPress MySQL database.
- [root@dev ~]# mysqldump -u root -p wordpress > /root/wordpress_DATE.sql
- [root@dev ~]#
Make sure to change wordpress in the above syntax to the database name being used for your WordPress installation. It should also be noted that if you have a tool such as the WordPress Database Backup plugin installed you could use that without having to login to the server to issue the above command. Just make sure you know the location of the database backups and understand the restore process should you run into issues.
- Analyze WordPress MySQL Database Schema: After you have a backup you can proceed to verify the proper table name for WordPress posts which by default is wp_posts. Many people however likely prepended something other than wp to the beginning of each of the MySQL tables during the install process. In my case this has been modified to something such as data_ instead of the default of wp_ so the wp_posts table is actually data_posts. To analyze your table structure SSH to the server, login to MySQL, and run the below SQL query.
- mysql> use wordpress
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -ADatabase changed
- mysql> show tables;
- data_users12 rows in set (0.00 sec)mysql>
I filtered any custom tables that are in my table output except for the APIAPP plugin table called amazoncache. The table you will be updating content in is the posts table but again it is important to understand the prefix added to the posts table. In this example the correct table is data_posts which will be used in the example outputs below.
- Prepare SQL Syntax: Now that you know the correct table name you should prepare the SQL syntax which should be similar to the below example.
- SQL: UPDATE data_posts SET post_content = REPLACE (post_content, 'amazonproduct=', 'amazonproducts asin=') WHERE post_content LIKE '%amazonproduct%';
The only item you should need to modify above is the table name which in this example is data_posts. The column being modified is post_content and we are updating the Amazon Product In A Post Plugin shortcode syntax from amazonproduct= to amazonproduct asin=. If you were using a different standard shortcode syntax you will need to modify the above syntax to mirror what was being used on your site as well but you can see the new format is (within square brackets) “amazonproducts asin=XXXXXXXXX” instead of (also in square brackets) “amazonproduct=XXXXXXXXX”
- Upgrade Plugin: With everything in place it is time to upgrade the Amazon Product In A Post Plugin on your WordPress installation. Since you are upgrading the plugin you should first backup the current version by downloading the Amazon Product In A Post Plugin folder to your local computer which is located at “/path/to/wp/install/wp-content/plugins/amazon-product-in-a-post-plugin”. Once the current plugin version is backed up you should delete the amazon-product-in-a-post-plugin folder followed by uploading the new folder. It is always best to delete the current directory so there are not any old files still being accessed by WordPress. Verify the Amazon Product In A Post Plugin is upgraded by visiting your WordPress admin site and clicking on the Plugins link in the left column. The Amazon Product In A Post Plugin should display version 3.5.2 similar to the below example image.
- Update APIAPP Shortcode Syntax In WP Posts: After the plugin has been upgraded it is time to issue the SQL command we prepared in step three which will modify the shortcode syntax to fall in line with the plugins current shortcode.
- mysql> UPDATE data_posts SET post_content = REPLACE (post_content, 'amazonproduct=', 'amazonproducts asin=') WHERE post_content LIKE '%amazonproduct%';
- Query OK, 3999 rows affected (36.00 sec)
- Rows matched: 4017 Changed: 3999 Warnings: 0mysql>
As you can see in the above example there were 4017 rows that had “amazonproduct” in the post_content column and 3,999 instances of “amazonproduct=” being replaced to “amazonproducts asin=”.
- Verify Shortcode Updated Successfully: Visit pages on your site where Amazon products have been included via the APIAPP shortcode to verify things are displaying properly. In my experience if one book was posted it did display incorrectly with the old shortcode however if there were multiple Amazon products only the first one displayed and displayed incorrectly at that. Below is how an Amazon product or products should display on your site with the new shortcode being used by Amazon Product In A Post Plugin.
Now that you have upgraded the Amazon Product In A Post Plugin on your WordPress installation you should start writing more articles and hopefully generating some money via this plugin.