[wp-hackers] Shortcode to call comments_template();

SWORD Studios info at swordstudios.net
Mon Apr 4 03:21:48 UTC 2011


Here's what I'm talking about:

http://swordstudios.net/hello-world/

Here's the content in the post:

<h2 class="ltcol tk-league-gothic">it's alive, it's alive <br />IT'S
ALIVE!!!! </h2>
                <article class="rtcol" >
<iframe title="YouTube video player" width="540" height="439" src="
http://www.youtube.com/embed/xos2MnVxe-c"></iframe>
</article>
<div class="clear"></div>
[comments-shareit]

On Sun, Apr 3, 2011 at 11:19 PM, SWORD Studios <info at swordstudios.net>wrote:

>
> Haha, wow, I should be going to bed when that happens (late night).  Thanks
> that immediately fixed it.
>
> Now the comments are coming in above the content in the post.  I have a few
> paragraphs of content then at the bottom is the shortcode.  However when you
> view the post it has the comments above everything else.  Any idea why?
>
> Jesse
> On Sun, Apr 3, 2011 at 11:09 PM, Matt Martz <matt at sivel.net> wrote:
>
>> On Sun, Apr 3, 2011 at 10:05 PM, SWORD Studios <info at swordstudios.net>
>> wrote:
>> > I'm attempting to call the comments_template(); function in a shortcode.
>> > Basically I want to call the comments template ONLY on a certain posts.
>> > Below is the shortcode function I wrote.  Everything works but the
>> > comments_template.
>> >
>> >
>> > function sword_comment_shortcode($sword_comment_atts) {
>> >  return '<h2 class="ltcol tk-league-gothic">I know you thought this was
>> > great, others will too.</h2>
>> >                   <article class="rtcol" ><span
>> > class=\'st_facebook_vcount\' st_title=\'{TITLE}\' st_url=\'{URL}\'
>> > displayText=\'share\'></span><span class=\'st_twitter_vcount\'
>> > st_title=\'{TITLE}\' st_url=\'{URL}\' displayText=\'share\'></span><span
>> > class=\'st_linkedin_vcount\' st_title=\'{TITLE}\' st_url=\'{URL}\'
>> > displayText=\'share\'></span>
>> >                            </article>
>> >                        <div class="clear"></div>
>> >                         <h2 class="ltcol tk-league-gothic">Share Your
>> > Thoughts!</h2>
>> >                   <article class="rtcol" >';
>> >
>> >  comments_template();
>> >
>> >  return '</article>
>> >  <div class="clear"></div>';
>> >
>> >  }
>> >  add_shortcode('comments-shareit', 'sword_comment_shortcode');
>>
>> Well first things first, your callback function is going to basically
>> exit after the first return and never meet the comments_template()
>> call, since you are doing a return before you run that function.
>>
>> --
>> Matt Martz
>> matt at sivel.net
>> http://sivel.net/
>>
>
>
>
> --
> *Jesse Friedman*   Founder / Lead Developer
> *SWORD Studios* | 508.50.SWORD info at swordstudios.net
> swordstudios.net @professor <http://twitter.com/professor>
>
>
>


-- 
*Jesse Friedman*   Founder / Lead Developer
*SWORD Studios* | 508.50.SWORD info at swordstudios.net
swordstudios.net @professor <http://twitter.com/professor>


More information about the wp-hackers mailing list