• Resolved Phil Johnston

    (@johnstonphilip)


    Hey,
    I have been trying for a while now to post the value of the “comment_post_ID” (the comment’s post number) in a tag for wp-commentsrss2.php in the item area (line 53). I know that this value does exist because it is used in part of the link (<link><?php comment_link() ?></link>) tag. I’ve been able to do this in the wp-rss2.php file like this:

    <postnum><?php the_ID(); ?></postnum>

    When viewed in the xml it looks like this:
    <postnum> 9 </postnum>

    This is exactly what I want it to look like in the wp-commentsrss2.php file as well. Although no matter which way I try to do it, it doesn’t seem to work.

    Anyone able to help me out?
    Thanks,
    Phil

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Phil Johnston

    (@johnstonphilip)

    I guess another way to say it –
    All I want is a way to get the value of comment_post_ID

    Thread Starter Phil Johnston

    (@johnstonphilip)

    bump?

    Thread Starter Phil Johnston

    (@johnstonphilip)

    I’ve kept looking around and trying things but I can’t seem to find anything that works. Maybe some one could at least tell me if it is possible or not?

    Don’t double post – usually it gets deleted…

    Thread Starter Phil Johnston

    (@johnstonphilip)

    I didn’t know if it was actually showing up.

    Thread Starter Phil Johnston

    (@johnstonphilip)

    Just to let you know,
    I finally found another way around to get this value.
    I realised that the get_the_title function (in wpincludes/template-functions-post.php) HAD to be using the comment’s post ID number in order to get the title.

    So I changed the function called “get_the_title” (about line 31) from:

    function get_the_title($id = 0) {
    $post = &get_post($id);

    $title = $post->post_title;
    if ( !empty($post->post_password) )
    $title = sprintf(__(‘Protected: %s’), $title);

    return $title;
    }
    _________________________________________
    to:

    function get_the_title($id = 0) {
    $post = &get_post($id);

    $title = $post->ID;
    if ( !empty($post->post_password) )
    $title = sprintf(__(‘Protected: %s’), $title);

    return $title;
    }
    _____________________________________

    And then put this as my tag in ‘wp-commentsrss2.php’:
    <postnum><?php $postnum = get_the_title($comment->comment_post_ID);
    printf(__(‘%1$s’), $postnum, get_comment_author_rss()); ?> </postnum>

    It outputs exactly what I wanted – the number of the post that the comment is related to. I know this probably isn’t the best way to do it because it makes the ‘get_the_title’ function do something it’s not supposed to. But right now I don’t really care as long as it is working. I tried writing a new function in ‘template-functions-post.php but I’m pretty sure that some of the variables are the same as the get-the-title function. If anyone has better know-how about writing functions and wants to add this that would be sweet.

    Phil

    Thread Starter Phil Johnston

    (@johnstonphilip)

    Ok,
    I’ve been able to re-write the function
    here it is:
    function get_postnum($id = 0) {
    $post = &get_post($id);

    $postnum = $post->ID;
    if ( !empty($post->post_password) )
    $postnum = sprintf(__(‘Protected: %s’), $postnum);

    return $postnum;
    }
    ———————-

    use this as your tag:

    <postnum><?php $postnum = get_postnum($comment->comment_post_ID);
    printf(__(‘%1$s’), $postnum, get_comment_author_rss()); ?> </postnum>

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘custom RSS2- trying to post “comment_post_ID” in a tag’ is closed to new replies.