Title: Shortcode echoes but doesn&#8217;t execute
Last modified: March 20, 2019

---

# Shortcode echoes but doesn’t execute

 *  [gamattox](https://wordpress.org/support/users/gamattox/)
 * (@gamattox)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/shortcode-echoes-but-doesnt-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
    -  This topic was modified 7 years, 2 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
    -  This topic was modified 7 years, 2 months ago by [Andrew Nevins](https://wordpress.org/support/users/anevins/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 2 months ago](https://wordpress.org/support/topic/shortcode-echoes-but-doesnt-execute/#post-11334964)
 * The shortcode is executed at the PHP level, not in the browser. When you add 
   a shortcode via jQuery, it’s being added in the browser. Your approach using 
   jQuery to build the shortcode is not going to work. You need to figure a way 
   to do this via PHP *before* the page contents are sent to the browser.
 *  Thread Starter [gamattox](https://wordpress.org/support/users/gamattox/)
 * (@gamattox)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/shortcode-echoes-but-doesnt-execute/#post-11339615)
 * Hi Steven,
 * Your answer is rather hard to accept. You are saying WordPress is unable to create
   dynamic content that uses ShortCodes. So shortcodes are essentially just a way
   to hardcode functionality and cannot be changed interactively?
 * Have you considered an AJAX solution that refreshes only the DIV that contains
   the modified ShortCode? Do you have any experience with such a solution? What
   about a plugin solution or a knowledgebase of code snippet solutions I could 
   review? Seems like there is a solution somewhere, I just need some thoughts on
   how to approach a solution that has worked for others.
 * I need to set the parameter of a shortcode based on a user’s selection from a
   table. Surely there is a code snippet out there to do this?
 * Thanks for your thoughts,
    Gary
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [7 years, 2 months ago](https://wordpress.org/support/topic/shortcode-echoes-but-doesnt-execute/#post-11339626)
 * Shortcodes are now more or less the “old way” of doing things as they’re being
   replaced by blocks, so I don’t expect much in the way of additional support for
   shortcodes.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shortcode echoes but doesn’t execute’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/shortcode-echoes-but-doesnt-execute/#post-11339626)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
