![]() |
|
Home | Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]() I would like to be able to put a product into the sidebar on some pages and I would like to use the product ID to minimise how much work is needed to change it. I have done this via a shortcode in a post or page but when I tried to use a the same shortcode in a text widget I can't get it to work - is this possible?
I followed the instructions and have this working properly if the shortcode is in a page or post, but copying the same shortcode into a text widget does not seem to work eg In a post [DFR:Embedded 150 Pic Cube?p=491100198966992] displays as the image In a widget [DFR:Embedded 150 Pic Cube?p=491100198966992] just shows as the text I tried adding add_filter('widget_text', 'do_shortcode'); to my theme - no luck for other plugins I have used the following to get the shortcode to work in a widget if ( function_exists ('name-of-plugin-function-that-does-shortcode')) { add_filter('widget_text', 'name-of-plugin-function-that-does-shortcode' ); } I can't try this since I don't know the name of the function for datafeedr shortcuts. The documentation (http://www.datafeedr.com/docs/item/185) says shortcodes are for pages or posts but it would be handy to be able to use this one in a text widget as well. Can you let me know if what I am trying is possible or let me know the name of the datafeedr shortcode function and I'll try the second method in my theme. Many thanks! |
#2
|
||||
|
||||
![]() Hi
It's not possible to add a shortcode to a Text widget. The only way to deal with this is to create a widget in the Factory, configure it to display the product(s) you want and then add that widget to your sidebar in the admin area of your site. Eric
__________________
![]() ![]() ![]() ![]() |
#3
|
|||
|
|||
![]() Many thanks Eric,
I did have success by following a longer winded method and have included it here in case it is of use to anyone else. Basically I created my own shortcode and wrapped the datafeedr_tag() function. By then using add_filter('widget_text', 'do_shortcode'); I have the shortcode functionality in my text widget. I pass in the view name and the product number as variables. /* Create our own shortcode to wrap a shop shortcode */ /* New shortcode is of the form [DWG_DFR view="Embedded 150 Pic Cube" productnum="491100198966992"]*/ function show_DFR_in_widget( $atts, $content = null ) { /* Datafeedr does not yet support shortcodes in a text widget, wrap the datafeedr shortcode and display this one */ extract( shortcode_atts( array ( 'view' => 'Sale Items', 'productnum' => '123456' ), $atts ) ); if ( function_exists ('datafeedr_tag') ) $DFR_result=datafeedr_tag($view.'?p='.$productnum) ; else $DFR_result='Datafeedr not configured'; return $DFR_result; } add_shortcode( 'DWG_DFR', 'show_DFR_in_widget' ); /*Add the filter to allow shortcodes to work in widget text areas */ add_filter('widget_text', 'do_shortcode'); Cheers, Brian |
#4
|
||||
|
||||
![]() That reminds me that you could use a plugin that allows you to embed PHP in the text widget. Then I think you would be able to use the datafeedr_tag() function found here: http://www.datafeedr.com/docs/item/185
__________________
![]() ![]() ![]() ![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Changing the text in tab | youngy | Questions | 1 | July 13th, 2011 09:11 AM |
Sub Cat text not centred | macfink | Questions | 6 | March 31st, 2011 02:20 PM |
Text Removal | macfink | Questions | 1 | March 29th, 2011 11:27 AM |