Get help. Give help. A Web Design and Development Community.

Strange issue with WP Shortcode

  • # April 5, 2013 at 5:56 am

    I have strange issue with WP Shortcode. I want to make shortcode which will put comments where i want it. Here is the shortcode:

    function custom_comment_func( $atts ){
    $comments = comments_template();
    return 'div class="comment-wrapper"' . $comments . '/div';

    add_shortcode( 'custom_comment', 'custom_comment_func' );

    And shortcode work’s but the problem is that instead to put comments on bottom where i put the shortcode it is always put’s it on top before content. Maybe some issue with execution ? I dont know. Please give some idea where i got wrong. Thanks.

    # April 5, 2013 at 7:34 am

    I’ve done it using buffer.
    Here is my solution:

    function bnt_custom_comment_func( $atts ){

    $output_string = ob_get_contents();
    return '
    ' .$output_string . '

    add_shortcode( 'bnt_custom_comment', 'bnt_custom_comment_func' );

    If there is other solution’s please tell.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We have a pretty good* newsletter.