wordpress笔记

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liu709127859/article/details/81283441

comments_template(); 获取评论模板

get_template_part( 'content/single', 'related');获取一个文件

数据库操作

        $my_email  = get_bloginfo ( 'admin_email' );
        $str       = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = $post->ID AND comment_approved = '1' AND comment_type = '' AND comment_author_email";
        $count_t   = $post->comment_count;
        $count_v   = $wpdb->get_var("$str != '$my_email'");
        $count_h   = $wpdb->get_var("$str = '$my_email'");

esc_attr转义并输出 sprintf 占位符

        <?php echo sprintf( __( '%s 条评论,访客:%s 条,站长:%s 条' , 'salong' ), esc_attr($count_t), esc_attr($count_v), esc_attr($count_h) ); ?>

猜你喜欢

转载自blog.csdn.net/liu709127859/article/details/81283441