I need to redirect the user to a specific page by placing a hyperlink just before a closing </ul>
tag (which is within a WordPress sidebar widget).
An example of what I am trying to achieve can be found below, using the WooCommerce Products widget which has been slightly modified to include an additional Specials hyperlink:
I am using the WooCommerce 2.9.1 plugin, and believe that the file I need to modify is the
class-widgets-products.php
file. This file is made up with the following code – http://pastebin.com/vgpSqa6X.
On line 178
I have placed the following, which will display a hyperlink taking the user to a Specials page on the website:
echo '<a href="'. get_site_url().'/specials/" class="go-to">» Specials</a>';
However, with this particular widget, it creates three separate instances and this will apply the hyperlink to All Products, Featured Products and On-sale Products.
How can I create separate hyperlinks that will apply to the widget, depending on which option has been selected in the admin menu?
For example, if the Featured Products option has been selected, it will output a Featured Products hyperlink at the bottom, and if the On-sale option has been selected, it will output a Specials hyperlink at the bottom.
Thank you.
The answer seems to lie in :
or :
…as the code you have pasted suggests.
Just evaluate this value with if’s (or switches, whatever you feel comfortable with) :