- This topic has 0 replies, 1 voice, and was last updated 15 years ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- The topic ‘Using PHP on the Sidebar or Widget (example: to display a button)’ is closed to new replies.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › General Stuff › Instructions/F.A.Q › Using PHP on the Sidebar or Widget (example: to display a button)
You can add button(s) to the sidebar by using a PHP function call.
Now if you are calling the function from the theme’s template file (sidebar.php, header.php, footer.php etc) then you are fine but there is another way to do this using the widgets which could be more practical in some cases.
1. Download and activate a PHP executable plugin (there are many) if you don’t have one already:
a) Executable PHP code plugin – http://wordpress.org/extend/plugins/php-code-widget/
b) Widgetify – http://wordpress.org/extend/plugins/php-widgetify/
c) You can find many more plugins here: http://wordpress.org/extend/plugins/search.php?q=PHP+executable&sort=
These plugins let you call php functions from the widgets (it’s similar to the Text widget but it lets you execute PHP code too).
2. Go to the widgets menu and add a “PHP Code” widget to the sidebar (where you want to display the “Add to Cart” buttons for example). Now, you can enter PHP code in this widget to display the button for example:
<?php echo print_eStore_buy_now_button(1); ?>
This will display a ‘Buy Now’ type button for the product with product id 1.
You can use any PHP code in a PHP widget.
Please refer to the WP eStore Shortcodes for a list of available functions:
http://www.tipsandtricks-hq.com/ecommerce/wp-estore-shortcodes-and-functions-reference-460