我试图在自定义区域显示特定用户的评论。我成功地做到了这一点,但问题是permalink结构。这段代码将url设置为禁用永久链接,如果我从设置中启用永久链接,那么这些url将开始给出404。
以下是im使用的代码:
<?
if(get_query_var(\'author_name\')) :
$curauth = get_userdatabylogin(get_query_var(\'author_name\'));
else :
$curauth = get_userdata(get_query_var(\'author\'));
endif;
$querystr = "
SELECT comment_ID, comment_post_ID, post_title, comment_content
FROM $wpdb->comments, $wpdb->posts
WHERE user_id = $uid
AND comment_post_id = ID
AND comment_approved = 1
ORDER BY comment_ID DESC LIMIT 5
";
$comments_array = $wpdb->get_results($querystr, OBJECT);
if ($comments_array): ?>
<ul>
<? foreach ($comments_array as $comment):
setup_postdata($comment);
echo "<li><a href=\'". get_bloginfo(\'url\') ."/?p=".$comment->comment_ID."\'>Comment on ". $comment->post_title. "</a><br />". $comment->comment_content . "</li>";
endforeach; ?>
</ul>
<? endif; ?>
所以这个url是www.mysite。com/p=xxxx。。如果永久链接作为mysite启用。com/post-perma-links/it开始在通过上述代码生成的这些链接上给出404。函数的其余部分工作正常,在这种情况下,有可能获得永久链接url而不是p=xxx?谢谢你的帮助干杯