将儿童排除在分类学术语之外

时间:2016-03-24 20:48:21

标签: php wordpress custom-post-type children custom-taxonomy

您好我有一个名为'support-team-doc'的自定义帖子类型和一个名为'support_team_docs'的自定义分类,其分类如下:

Support Teams Group
-- Accounts
-- IT
-- Marketing
-- Risk & Compliance

每个类别都有很多帖子;我不希望子类别中的帖子显示在任何类别页面上; atm子类别的帐户,营销,风险合规中的任何帖子都显示如下:'support-teams-group';我尝试过以下方法:

<?php
$termsTextarea = get_queried_object();

$args = array(
    'post_type' => 'support-team-doc',
    'tax_query'=>
        array(
            'taxonomy' => 'support_team_docs',
            'field' => 'slug',
            'terms' => $termsTextarea->slug,
            'include_children' => false,
        ),
);
$query1 = new WP_Query( $args );
while ( $query1->have_posts() ) : $query1->the_post(); 

    get_template_part( 'content', 'support_team_docs' );

endwhile; ?>

我不知道我做错了什么。

1 个答案:

答案 0 :(得分:1)

tax_query是一个多维数组...您在当前代码中缺少一个数组元素。试试这个:

import urllib
from lxml import html
from urlparse  import urljoin
def main():
    url = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_IEC_14496-26_2010_Bitstreams/DVD1/mpeg4audio-conformance/compressedMp4/"

    page = html.fromstring(urllib.urlopen(url).read())

    for link in page.xpath("//a/@href"):
        runme("wget " + urljoin("http://standards.iso.org/", link))