Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to setup a page and extract comments from an external post. I took this advice how to pull wordpress post comments to a external page and now I have this get_comments code at my disposal:

<?php 
$comments = get_comments('post_id=15');
    foreach($comments as $comment) :
    echo($comment->comment_author);
endforeach;
?>

Where on the page do I place this? Sorry for the noob question!

share|improve this question
    
Well, where do you want comments to appear? How are you setting up page - custom page template? –  Rarst Nov 10 '11 at 12:40
    
Yes custom template and I can say that I've progressed since last week. Thanks for replying. –  AlxVallejo Nov 17 '11 at 20:12
    
if you solved this by yourself please post this as an answer so others can benefit from it. If not (for any reason) and you no longer need answer to this specific question we can close it. –  Rarst Nov 17 '11 at 20:39

1 Answer 1

up vote 0 down vote accepted

I would rarely use 'echo' in WordPress template themes because it can cause output to appear before the loops are even executed (aka, at the top of the page).

In this instance, I used the get_comments function within a function that hooked onto the content output:

add_filter('the_content', 'includePosts', 1);

Within the function includePosts, I have set $Comments to appear in the $content variable and I return $content just before adding the filter.

$content is used within the wp core function 'the_content' (includes/wp-page-template).

function the_content($more_link_text = null, $stripteaser = 0) {
$content = get_the_content($more_link_text, $stripteaser);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.