我已经想出了解决我问题的办法。这是我所做的。。。
Note:<这是在考虑帖子,因此评论,在\'Article\' post类型,从而创建永久链接,如下所示:site.com/article/post-name/#comments.对于其他用途,应进行调整
修复问题#1(&#3:
if ( !is_admin() )
add_filter(\'get_comment_link\', \'my_comment_post_redirect\');
function my_comment_post_redirect($location){
// Retrieve the URL based on current language up to the post-type (\'article\')
$currUrl = preg_replace(\'/(.*article\\/).*/\', \'$1\', $_SERVER["HTTP_REFERER"]);
// Retrieve the URL from the post name to the location of the comment
// (ie. comment page & number/ID)
$cmntPage = preg_replace(\'/.*article\\/(.*)/\', \'$1\', $location);
// Comment page #1 has special redirection, thus...
$cmntPageNum = preg_replace(\'/.*comment-page-(.*)\\/.*/\', \'$1\', $cmntPage);
// If on first comment page...
if ($cmntPageNum == 1) {
// ...then get rid of comment page from permalink
$cmntPage = preg_replace(\'/(.*)comment-page-.*\\/(.*)/\', \'$1$2\', $cmntPage);
}
return $currUrl.$cmntPage;
}
UPDATED: 上述代码还将影响
back-end 所以我补充道
if ( !is_admin() )
以防止其发生。
对于问题2,我为每个链接创建了一个函数(下一个和上一个):
function def_get_next_comments_link($label, $max) {
// Get the complete code generated by the function
// (which includes the <a> tag)
$navLink = get_next_comments_link($label, $max);
// Retrieve the base URL up to the post-type \'article\'
$baseUrl = preg_replace(\'/.*(http:.*article\\/).*/\', \'$1\', $navLink);
// Replace the base URL with the one for the current language
return str_replace($baseUrl, qtrans_convertURL($baseUrl), $navLink);
}
function def_get_previous_comments_link($label) {
// Get the complete code generated by the function
// (which includes the <a> tag)
$navLink = get_previous_comments_link($label);
// Retrieve the base URL up to the post-type \'article\'
$baseUrl = preg_replace(\'/.*(http:.*article\\/).*/\', \'$1\', $navLink);
// Replace the base URL with the one for the current language
return str_replace($baseUrl, qtrans_convertURL($baseUrl), $navLink);
}
然后我调用了链接所在的函数。
这对我有用。:)