• Hello Again,

    Slowly understanding WordPress but as I look through their site, I don’t see anything that shows what variables/classes/functions WordPress uses. This site: https://phpxref.ftwr.co.uk/wordpress/nav.html?_functions/index.html isn’t too bad.

    What I’m trying to do, is for each comment made for a post. How do you retrieve the comment for that specific post?

    I know the $wp_posts is a stdClass which shows how many comments are related to the post but there’s no ID linking the comments to the post.

    Array
    (
    [0] => stdClass Object
    (
    [ID] => 1
    [post_author] => 1
    [post_date] => 2011-04-28 23:15:19
    [post_date_gmt] => 2011-04-28 23:15:19
    [post_content] => Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
    [post_title] => Post1
    [post_excerpt] =>
    [post_status] => publish
    [comment_status] => open
    [ping_status] => open
    [post_password] =>
    [post_name] => hello-world
    [to_ping] =>
    [pinged] =>
    [post_modified] => 2011-04-29 22:26:44
    [post_modified_gmt] => 2011-04-29 22:26:44
    [post_content_filtered] =>
    [post_parent] => 0
    [guid] => http:/….
    [menu_order] => 0
    [post_type] => post
    [post_mime_type] =>
    [comment_count] => 2
    [filter] => raw
    )

    )

    So what do I need to do, to show the comments for that post?

    Thanks,

    Til

    P.S. if I missed something just let me know and this is the code I have so far:

    <?php
    define('WP_USE_THEMES', false);
    require(DOCUMENT_ROOT . '/wordpress/wp-blog-header.php');
    $wp_posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
    
    	if($wp_posts[0]->post_title == $product['name']) {
            foreach ($wp_posts as $wp_post) {
              start_wp();
              the_date();
              echo '';
              the_title();
              the_excerpt();
    
            }
    }
    
    ?>

    [please mark all code using the ‘code’ button;
    for any code longer than 10 lines, please use the pastebin]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tilmishra

    (@tilmishra)

    Thanks for the info.

    I’ve tried that but I’m not getting any comments.

    <?php
    define(‘WP_USE_THEMES’, false);
    require(DOCUMENT_ROOT . ‘/wordpress/wp-blog-header.php’);
    $wp_posts = get_posts(‘numberposts=10&order=ASC&orderby=post_title’);

    if($wp_posts[0]->post_title == $product[‘name’]) {
    foreach ($wp_posts as $wp_post) {
    start_wp();
    the_date();
    echo ‘
    ‘;
    the_title();
    the_excerpt();
    echo ‘

      ‘;
      wp_list_comments();
      echo ‘

    ‘;
    }
    }

    ?>

    So what am I doing wrong here?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Retrieving Comments from Blog Posts’ is closed to new replies.