How to include a WordPress Shortcode in your Code, not in the Posts Section

I want to insert a hardcoded short code in my code, and not from the usual Text Editor we usually use.

Basically I want this to add a gallery, and the user doesn’t need to change the shortcode from the CMS so I will be hardcoding this.

Read More

How would I need to do this, I tried to just post it in my .php file but it doesn’t work.

This is the code I want to add:

[jj-ngg-jquery-slider gallery=”1″ width=”866″ height=”341″ ]

Related posts

Leave a Reply

3 comments

  1. shortcodes were created to include in post or pages. I could be wrong but wordpress checks the input of a post and if it finds a shortcode it will replace it with the html. I don’t think it will work if you add shortcodes in your .php file because wordpress doesn’t look for shortcodes in your php files

    You could just create a function in functions.php to generate the html you need. Then you just call that function within your theme .php file. That’s how most plugins are made. Shortcode for post & pages and function in the php files.

    example:

    <?php echo myGallery(array('gallery'=>1, 'width'=>866, 'height' => 341); ?>