单个Wordpress页面中的两个帖子类型/类别?
答
<div class="leftcol">
<?php $args = array('post_type' => 'video_post'); //select only posts of type 'video_post'
$wp_query = new WP_Query($args);
while (have_posts()) : the_post(); ?>
<div class="post">
<h3><?php the_title() ?></h3>
<?php the_content() ?>
</div>
<?php endwhile; rewind_posts(); ?>
</div>
<div class="rightcol">
<?php $args = array('post_type' => 'audio_post'); //select only posts of type 'audio_post'
$wp_query = new WP_Query($args);
while (have_posts()) : the_post(); ?>
<h2><?php the_title() ?></h2>
<?php endwhile; rewind_posts(); ?>
</div>
我假设你知道编辑主题的基础知识,但如果没有,只是这么说!或者,您可以使用'cat'而不是'post_type'来按照类别分开您的帖子,而不是两种不同的类型。如果您不打算添加任何额外字段来启用音频/视频功能,我建议使用类别。
答
我不知道如果我理解得很好,但我会使用的Widget插件的逻辑http://wordpress.org/extend/plugins/widget-logic/
如果你想死您的模板,您可能需要检查query_posts()reset_posts Widget和(做)finctions:http://codex.wordpress.org/Function_Reference/query_posts
你知道如何使用WordPress Codex吗?你知道这个循环是如何工作的吗?如果是的话,你可能想用第二种方式,如果不尝试用第一种方法做。
祝你好运, gezope