• Hi I can’t figure out how to display comments from an image to a page on my website that is outside the blog.

    For example I want to show only the comments for: https://www.mysite.com/blog/?attachment_id=62

    I know how to only show comments for a post, See below). I think I just need to tweak out the query but I am not sure to what?

    Thanks

    <?php include('blog/wp-blog-header.php');  ?> 
    
    <?php
    // retrieve one post with an ID of 1
    query_posts('p=1');
    
    // the Loop
    while (have_posts()) : the_post(); 
    
     $withcomments = true; comments_template(); // displays the comments
    
    endwhile;
    ?>
Viewing 1 replies (of 1 total)
  • Thread Starter sherbert99

    (@sherbert99)

    I got it.

    <?php include('blog/wp-blog-header.php');  ?> 
    
    <?php
    
    $args = array(
    	'post_type' => 'attachment',
    	'numberposts' => 5,
    	'post_status' => null,
    	'post_parent' => null, // any parent
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ($attachments as $post) {
    
     ?>
    
    <?php
    	setup_postdata($post);
    
    	if(get_the_ID() == "62") {  
    
    	the_attachment_link($post->ID, true);
    	 $withcomments = true; comments_template();
    	 }
    ?>
    
    <?php
    
    	}
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Display comments from specific image to a page’ is closed to new replies.