Support » Themes and Templates » Comment template on certain page

  • Resolved baszer



    I have a page called comments, I also created a custom comment field, now I want to connect these 2. But I can’t figure out how.

    This is my code
    <?php comments_template( '/outofthebox-comments.php', true ,$post_id = 250 ); ?>

    250 is the id of the comment page

    what do I do wrong?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer




    there is no third argument for post ID.

    What do you mean with custom comment field?

    in that document:

    Uses global: (array) $comment List of comment objects for the current post
    Uses: $wpdb
    Uses: $id
    Uses: $post
    Uses: $withcomments Will not try to get the comments if the post has none.

    so I thought, I can get the comment form for id but I dont know how.

    I want to have a comment form in a page, but from another page.

    Moderator keesiemeijer



    What you could try is load the page and get the comments and comment form:

    $post = get_page($id = 650);
    <?php comments_template( '', true ); ?>
    <?php wp_reset_postdata(); ?>

    In this example, after you make a comment you will be redirected to the page with $id = 650.

    To remedy this you can put this in your theme’s functions.php:

    add_filter('comment_post_redirect', 'redirect_after_comment');
    function redirect_after_comment($location)
    return $_SERVER["HTTP_REFERER"];

    Thank you very much,

    this did the trick!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Comment template on certain page’ is closed to new replies.