我有一个用Wordpress建立的用户评论网站,似乎不能只在主页上显示一个类别。
我试过了:
<?php get_header(); ?>
<?php $top_counter=1 ?>
<?php
$blog_hero = of_get_option('blog_hero');
if ($blog_hero && ! is_category()){
?>
<div class="clearfix row-fluid">
<div class="hero-unit">
<h3>thanks stack-exchange help needed.</p>
<br />
</p>
</div>
</div>
<?php
}
?>
<div id="content" class="clearfix row-fluid">
<div id="main" class="span8 clearfix" role="main">
<? function customf_process_wp_query($posts_data,$post_type=null,$post_rate=null){
wp_reset_query();
query_posts($posts_data);
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
if($post_type==3){
$in_top=false;
foreach($post_rate as $key=>$top_post_id){
if($top_post_id->ID==get_the_ID()) $in_top=true;
}
if($in_top) continue;
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
<header>发布于 2014-02-03 18:18:40
query_posts( array('your-custom-taxonomy' => 'category name', 'post_type' => 'your_post_type_here') );将上面的代码替换为
query_posts($posts_data);并将your-custom-taxonomy和your_post_type_here替换为所需的参数。希望这能有所帮助
发布于 2014-02-03 18:38:00
使用标准循环初始化器:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>只需更改为:
<?php if ( have_posts() ) : while ( have_posts() && the_category() == $home_page_cat ) : the_post(); ?>https://stackoverflow.com/questions/21522891
复制相似问题