/wp-content/themes/zhihu-child/
。functions.php
注册两种自定义文章类型:register_post_type('question', 【'public'=>true,'label'=>'问题','supports'=>【'title','editor','comments'】】);
register_post_type('answer', 【'public'=>true,'label'=>'答案','supports'=>【'editor'】】);
single.php
为 single-question.php
,使用两栏:主栏显示问题+答案循环,侧边栏放作者卡片与“相关问题”。[/span>button class="upvote" data-id=" the_ID(); ?>"↑ [/span>span echo get_vote_count(); ?>spanbutton
wp_enqueue_script
加载 vote.js
,通过 wp_ajax_nopriv_upvote
钩子处理 Ajax 投票。style.css
中加入:.answer-content img{max-width:100%;height:auto;margin:1em 0;}
.answer-content pre{overflow-x:auto;background:#f6f8fa;padding:1em;border-radius:4px;}