0

I'm really struggeling with the try to output a wordpress shortcode that looks like this:

[urlparam attr="value" param="searchpre"]

with a js script that dynamically builds a html table on my webpage. The shortcode should be passed out right inside this html element:

g='<input type="search" class="'+b.sFilterInput+'" />'

Maybe my trying is foolish - i have to add im really a javascript beginner and this would basically be nothing more for me than a cheat to avoid more work and knowledge with javascript in general and about the .js file im trying to manipulate.

3
  • are you place this inside wp editor or in php file? Commented Nov 17, 2016 at 11:31
  • where are you calling this shortcode with in a php file or js file? Commented Nov 17, 2016 at 12:10
  • its inside a .js file Commented Nov 17, 2016 at 13:17

1 Answer 1

1

Shortcodes are executed with do_shortcode() function. And PHP is executed before Javascript. So to insert any shortcode with js, you are going to need AJAX.

Sign up to request clarification or add additional context in comments.

1 Comment

this is very helpful - means just inserting the shortcode with a javascript that gets fired after php is basically useless unless there is nothing that starts the process in parts allover again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.