首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Wordpress主页上仅显示单个类别

在Wordpress主页上仅显示单个类别
EN

Stack Overflow用户
提问于 2014-02-03 16:43:44
回答 2查看 51关注 0票数 0

我有一个用Wordpress建立的用户评论网站,似乎不能只在主页上显示一个类别。

我试过了:

代码语言:javascript
复制
<?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>
EN

回答 2

Stack Overflow用户

发布于 2014-02-03 18:18:40

代码语言:javascript
复制
query_posts( array('your-custom-taxonomy' => 'category name', 'post_type' => 'your_post_type_here') );

将上面的代码替换为

代码语言:javascript
复制
query_posts($posts_data);

并将your-custom-taxonomyyour_post_type_here替换为所需的参数。希望这能有所帮助

票数 0
EN

Stack Overflow用户

发布于 2014-02-03 18:38:00

使用标准循环初始化器:

代码语言:javascript
复制
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

只需更改为:

代码语言:javascript
复制
<?php if ( have_posts() ) : while ( have_posts() && the_category() == $home_page_cat ) : the_post(); ?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21522891

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档