Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Using shortcode in template, not in a post (shortcode does not work)

3 replies [Last post]
Reply

Hello,

I use Wordpress 3.3.1 and JW Player Plugin for WordPress 1.5.5

Everything works fine when I'm adding videos to posts. But I'm developing a custom portfolio theme where I'm opening attachments from gallery with lightbox effect. The attachment itself loads in pup-up lightbox div and uses 'attachment.php' wordpress template. In this template I'm checking for attachment type, if it's 'image' - I'm showing IMG tag, and if it's video - I'd like to show the JW Player.

Wordpress allows to use shortcodes outside the loop in any area of template using special function:
echo do_shortcode('[jwplayer config="My Player" mediaid="128"]');
But it does not work with JW shortcode it outputs the text [jwplayer config="Prana Player" mediaid="128"] instead of parsing and executing shortcode. My other custom shortcodes are working.

In some threads on this forum I've read that [jwplayer] isn't actually a shortcode, but a filter. I've tried to figure out how to use it as a filter but failed.

Is it possible to execute this shortcode outside the Wordpress editor and how to do it?

The second option I'm thinking about is to use manual embedding. Am I diggin' in right direction? Much more code and effort but can work, I guess.

Reply

Problem solved - I manually embedded JW player. Less code, less files, no extra WP plugin calls etc. Of course, this solution is for those who have some technical knowledge but it's dead solid and working like a charm.

Reply

I'm having the same problem getting the wordpress plugin to work with my index.php theme file. How exactly did you get it to work manually?

Reply

@Ihor,

That approach is certainly an effective way of doing it particularly when you don't need any of the other functionality provided by the plugin.

@Grassrootz

Unfortunately do_shortcode won't work in the case of the JW Player plugin. We had to provide our own implementation due to some syntax limitations. The plugin instead makes the function "jwplayer_tag_callback" available for use. You can pass in the tag and it should return the necessary embed code.

Thanks.

Post new comment

  • Allowed HTML tags: <code> <blockquote> <em> <strong> <strike> <ul> <li> <ol>
  • You may post code using <code>...</code> .
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options