【问题标题】:Wordpress 3.6: Page under categoryWordpress 3.6:类别下的页面
【发布时间】:2013-09-16 23:43:47
【问题描述】:

问题: 我的菜单栏包含一组类别。帖子自动对齐。一个新的插件基于 Pages。页面例如'p1' 总是在主站点上。

理念: 创建一个模板,将页面分配给特定类别,例如“p1”->“c1”。找到一段代码

<?php if (is_category('c1')) : ?>

问题是我不知道如何告诉程序:

if (is_category('c1')) :  show page / vice versa?>

我该怎么做?

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    您将需要页面和类别之间的命名标准。完成后,您可以执行以下操作(或类似的操作):

    <?php if(is_category('c1)) : ?>
    <?php query_posts('category_name=c1&order=asc');
    if ( have_posts() ) : while( have_posts() ) : the_post();?>
        <div class="pageWrapper">
          <h3><?php the_title(); ?></h3>
          <?php the_content(); ?>
        </div>
    <?php endwhile; else: ?>
    <p>No content was found</p>
    <?php 
         endif; 
    wp_reset_query();//If writing your own queries, always a good idea to reset it. ?>
    

    【讨论】:

      猜你喜欢
      • 2017-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-23
      • 2015-06-27
      • 2013-03-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多