WordPress.org

Ready to get started?Download WordPress

Forums

Add Post Title to Comments Feed (9 posts)

  1. andymatic
    Member
    Posted 9 years ago #

    I'm wanting my comments feed to have more information besides: 'By: Commenter'. I'd like for it to read:

    Commenter on 'Post Title'

    I've been tinkering with the arrays and variables but I'm not even sure if the comments array has the post title in it.

    Any ideas? Thanks!

  2. Kafkaesqui

    Posted 9 years ago #

    Try this for getting the post title:

    <?php echo $post->post_title; ?>

  3. andymatic
    Member
    Posted 9 years ago #

    Nope - that's not it - it's giving me the title of most recently published post for the title of all the comment feed items. I think this is because I'm out of the wp loop right?

  4. Kafkaesqui

    Posted 9 years ago #

    Alrighty, then try this one:

    <?php echo get_the_title($comment->comment_post_ID); ?>

  5. andymatic
    Member
    Posted 9 years ago #

    It's weird, '$comment->comment_post_ID' outputs the correct post ID# per commetn but '<?php echo get_the_title($comment->comment_post_ID); ?>' still pops in the title of the most recent published post.

  6. Kerim
    Member
    Posted 9 years ago #

    Has anyone solved this one?

  7. Kerim
    Member
    Posted 9 years ago #

    There seems to be a bug report on this, but I can't tell whether it has been fixed or not:

    http://mosquito.wordpress.org/view.php?id=1282

  8. KerimFriedman
    Member
    Posted 9 years ago #

    Anyone know the status of this?

  9. KerimFriedman
    Member
    Posted 9 years ago #

    OK. I think I figured it out. The bug report includes a "patch" which is basically a way to hack the code. Here is what I did, use with discression since I don't know what I'm doing:

    Open the file wp-commentsrss2.php in your root WP directory.

    Find line #52, with this code:

    <title>by: <?php comment_author_rss() ?></title>

    Replace that with this:

    <title><?php if ( (! is_single()) || (! is_page()) ) {
    $title = get_the_title($comment->comment_post_ID);
    $title = apply_filters('the_title', $title);
    $title = apply_filters('the_title_rss', $title);
    echo "Comment on $title";
    } ?> by: <?php comment_author_rss() ?></title>

    Hopefully that will do the trick!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.