WordPress.org

Ready to get started?Download WordPress

Forums

Specifying post id (8 posts)

  1. jland
    Member
    Posted 7 years ago #

    Let's say I have a page, but I want to get comments from a post with a different ID number.

    how do I get comments that are associated with certain post id's?

  2. moshu
    Member
    Posted 7 years ago #

    Try it again...
    You mean you want comments from post ID 123 to be displayed on your page ID 789?
    I don't think that would work.

  3. jland
    Member
    Posted 7 years ago #

    yes!
    ...why not?

    okay, so what I actually want is for comments from post id 33 to be displayed on my dashboard.

    When I threw in the comment_template tag (with some modifications so it'll work on a non-page/post page) it randomly chose to display comments from post id 29. How do I change that number to 33?

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Set the $post->ID global variable to the post id you want before you call the comments_template() function.

    $post->ID = 33;
    comments_template();
  5. jland
    Member
    Posted 7 years ago #

    WOW it worked!!!!! dang I didn't know you can just set $post->ID to a number. That's so easy. I can't believed I searched the WHOLE morning for this simple little thing. Thank you thank you thank you!!!

    now I have a message board on my dashboard :D

  6. danjul2
    Member
    Posted 6 years ago #

    I have the same prob. i want to have a post or a page comment to my index. and use it as a guestbook/comment.

    when changeing to "$post->ID = 33;" the comment-list lists posts from 33. but when writing a comment it still writes it to the first comment thats on the index page. and that is "51"

    and it also says "11 Comments", and thats from post "51"

    help me out please!

  7. danjul2
    Member
    Posted 6 years ago #

    Is there some more code i must call soo that the comment field will understand that its $post->ID = 33 and not the last post in the news feed....
    like $comment->ID or something like that...

    Help needed!

  8. danjul2
    Member
    Posted 6 years ago #

    ok, found it out..

    $id = 86; $post->ID = 86; comments_template();

    $post->ID will only call the list off comments
    while $id will call the numbers of comments and fix the submit form

    hope it helps someone.. cheers

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags