Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress根据类别和标签将档案分成5个部分_Php_Wordpress - Fatal编程技术网

Php Wordpress根据类别和标签将档案分成5个部分

Php Wordpress根据类别和标签将档案分成5个部分,php,wordpress,Php,Wordpress,在我的网站上(目前是PHP5,wordpress 2.8.5) 我有很多类别总计=150。 每个类别都是一个城市名称,即:巴黎,这有一个与此类别关联的标签。 ie:酒店、体育、酒吧、娱乐、食品总计->5 在我的归档页面上,我希望根据我的标签生成一个选项卡式分区。 即: 标签1:标签->酒店->列出所有来自巴黎的带有所选标签的帖子 标签2:标签->体育->列出所有来自巴黎的带有所选标签的帖子 标签3:标签->条->等…等 单击链接到存档页面的类别后,该页面被拆分为我的5个基本部分,每个基本部分都需

在我的网站上(目前是PHP5,wordpress 2.8.5) 我有很多类别总计=150。 每个类别都是一个城市名称,即:巴黎,这有一个与此类别关联的标签。 ie:酒店、体育、酒吧、娱乐、食品总计->5

在我的归档页面上,我希望根据我的标签生成一个选项卡式分区。 即:

标签1:标签->酒店->列出所有来自巴黎的带有所选标签的帖子
标签2:标签->体育->列出所有来自巴黎的带有所选标签的帖子
标签3:标签->条->等…等

单击链接到存档页面的类别后,该页面被拆分为我的5个基本部分,每个基本部分都需要应用自定义查询来显示帖子

刚才的页面代码看起来与任何默认归档页面几乎相同

$post = $posts[0];
if (is_category()) { ?>

    <h2 class="title"><?php single_cat_title(); ?></h2>
    <div style="border-bottom:1px dotted #ccc; text-align:justify;">
<?php echo category_description( $category ); ?>  
    <br />
    <br />  
    </div>  } // end if category

Tab 1:
<strong>Hotels</strong>
<?php query_posts('tag=hotels&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="title"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></div>
<div><?php the_excerpt(); ?></div>
<br />
<?php endwhile; endif; ?>

Tab 2:
<strong>Restaurants</strong>
<?php query_posts('tag=restaurants&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="title"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></div>
<div><?php the_excerpt(); ?></div>
<br />
<?php endwhile; endif; ?>
$post=$posts[0];
如果(是_category()){?>


}//结束如果类别 表1: 酒店
表2: 餐厅
现在页面加载了,但每个选项卡部分只会列出所有帖子和相关标签,而不会过滤类别。。。因此,tag酒店的所有帖子都将被列出(其中有5个帖子,即:showposts=5)

所以我的问题是:

是否可以过滤类别,然后根据标记再次过滤?

使用get\u query\u变量获取查询的类别


如果(是_category()){
$cat=get_query_var('cat');

然后在查询中,例如使用


查询帖子('tag=hotels&showposts=5&cat='。$cat);