custom RSS2- trying to post “comment_post_ID” in a tag
-
I guess another way to say it –
All I want is a way to get the value of comment_post_IDbump?
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…
I didn’t know if it was actually showing up.
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
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>
- The topic ‘custom RSS2- trying to post “comment_post_ID” in a tag’ is closed to new replies.
(@johnstonphilip)
17 years, 8 months ago
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