您的位置:首页 > 其它

Private属性文章无法显示

2005-03-18 20:37 429 查看

Show private entries when logged in

http://wiki.cornbreadtree.org/index.php?title=How_do_I_set_up_Wordpress_on_cornbreadtree.org%3F#Show_private_entries_when_logged_in

I have no idea why this bug hasn't been fixed in the Wordpress 1.5 codebase, but $user_ID never seems to be set properly when PHP goes to the database. Call
get_currentuserinfo()
immediately before to ensure all the posts are retreived.

wp-includes/classes.php:

get_currentuserinfo();[/b]
// Get private posts
if (isset($user_ID) && ('' != intval($user_ID)))
$where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
else
$where .= ')';

Once all the posts are loaded (when the owner is logged in, of course), distinguish between private and published posts with the following hack:

wp-includes/template-functions-post.php:

function get_the_title($id = 0) {
global $post, $wpdb;

if ( 0 != $id ) {
$id_post = $wpdb->get_row("SELECT post_title, post_password FROM $wpdb->posts WHERE ID = $id");
$title = $id_post->post_title;
if (!empty($id_post->post_password))
$title = sprintf(__('Protected: %s'), $title);
}
else {
$title = $post->post_title;
if (!empty($post->post_password))
$title = sprintf(__('Protected: %s'), $title);
}
if ($post->post_status == "private") {

$title = sprintf(__('Private: %s'), $title);

}[/b]
return $title;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐