Shortcode echoes but doesn’t execute
-
When I manually enter a shortcode into a column text object in the editor and then refresh the page my shortcode works perfectly as expected. However, when I programatically set the text of the same column text object using JQuery with the SAME shortcode string the shortcode does not execute and is merely echoed to the screen.
The code below allows a user to move across a table and select a row then detect the contents of a cell on that row. The cell contents are then added to a string variable ($trendingstock) to create the shortcode. The newly created shortcode string is then inserted into the column text object (.trendingstockchart.text). The shortcode appears as a correctly formated shortcode but does not execute. It is merely echoes to the column text object.
Anyone have thoughts on how can I get the shortcode to execute programatically?
jQuery(document).ready(function($){ $( '.tablepress-id-7' ).on( 'click', 'tr', function() { var currentRow=$(this).closest("tr"); // get closest row number clicked var $symbol=currentRow.find("td:eq(0)").text(); // get symbol in first column of current row var $trendingstock = '[finviz ticker= ' +$symbol +']'; // build a shortcode string with symbol selected alert("The symbol selected was: " + $symbol + " and the shortcode is " + $trendingstock ); // for debug purposes only $('.trendingstockchart').text ($trendingstock); // set column text object value to shortcode string <strong>$('.trendingstockchart').refresh(); // refresh to cause the shortcode to execute --- FAILS HERE !!</strong> }); });
Thanks,
Gary
- The topic ‘Shortcode echoes but doesn’t execute’ is closed to new replies.