On Mon, Mar 26, 2012 at 1:56 PM, Diana K. Cury <diana...@gmail.com> wrote:
> Sorry for bother,
> I just can't understand why my plugin isn't working, the post type screen is ok, but the shortcode action does'nt work at all.
> When adding [mensagem], it supposed to add the form into the page, but anything show up when doing so :( > ... > add_shortcode( 'mensagem', 'mensagem_shortcode',6 ); > ... > //cria shortcode > function mensagem_shortcode() { > do_action('wp_head','mensagem_form'); > include('form.php'); > }
Shortcodes are never, ever, supposed to produce output. They're supposed to *return* output.
I'm using the do_action to put content on header when using the shortcode, I don't really know how could I put scripts, css and else only when the shortcode is being used only. Is there someway?
----- Original Message ----- From: "Otto" <o...@ottodestruct.com> To: <wp-hack...@lists.automattic.com> Sent: Monday, March 26, 2012 4:38 PM Subject: Re: [wp-hackers] My plugin doesn't work online :( Shortcode
loadingorder?!
On Mon, Mar 26, 2012 at 1:56 PM, Diana K. Cury <diana...@gmail.com> wrote: > Sorry for bother,
> I just can't understand why my plugin isn't working, the post type screen > is ok, but the shortcode action does'nt work at all.
> When adding [mensagem], it supposed to add the form into the page, but > anything show up when doing so :( > ... > add_shortcode( 'mensagem', 'mensagem_shortcode',6 ); > ... > //cria shortcode > function mensagem_shortcode() { > do_action('wp_head','mensagem_form'); > include('form.php'); > }
Shortcodes are never, ever, supposed to produce output. They're supposed to *return* output.
The shortcode isn't processed until the header has already finished and you're displaying the content later on the page. Better to enqueue scripts and such into the footer if you have to do it that way.
However, I was really referring more to your includes and lack of a "return" on the shortcode. That's your main problem.
-Otto
On Mon, Mar 26, 2012 at 5:15 PM, Diana K. Cury <diana...@gmail.com> wrote:
> I'm using the do_action to put content on header when using the shortcode, I > don't really know how could I put scripts, css and else only when the > shortcode is being used only. Is there someway?
> ----- Original Message ----- From: "Otto" <o...@ottodestruct.com> > To: <wp-hack...@lists.automattic.com> > Sent: Monday, March 26, 2012 4:38 PM > Subject: Re: [wp-hackers] My plugin doesn't work online :( Shortcode > loadingorder?!
> On Mon, Mar 26, 2012 at 1:56 PM, Diana K. Cury <diana...@gmail.com> wrote:
>> Sorry for bother,
>> I just can't understand why my plugin isn't working, the post type screen >> is ok, but the shortcode action does'nt work at all.
>> When adding [mensagem], it supposed to add the form into the page, but >> anything show up when doing so :( >> ... >> add_shortcode( 'mensagem', 'mensagem_shortcode',6 ); >> ... >> //cria shortcode >> function mensagem_shortcode() { >> do_action('wp_head','mensagem_form'); >> include('form.php'); >> }
> Shortcodes are never, ever, supposed to produce output. They're > supposed to *return* output.