如何在Wordpress中的类别页面上显示所有帖子

时间:2015-04-25 05:55:16

标签: php wordpress

我有一个类别名称'趋势'和'顶部'我想显示这两个类别页面上的所有帖子。我不想编写自定义查询我想编辑“global $ wp_query;”对象并从查询中删除“cat”以显示所有帖子。

怎么可能?

我的代码快照:

    global $wp_query;
    if (isset($wp_query->query_vars[$monstrotheme->settings->slugs->frontendPosting->addNew])) {
        $this->data['specialPage'] = 'frontend-submit';
        $this->data['currentContentLayout'] = 'page';
    } else if ($wp_query->query_vars['pagename'] == $monstrotheme->settings->slugs->login->login) {
        $this->data['currentContentLayout'] = 'frontPage';
    } else {
        if (is_front_page() || is_404()) {
            $this->data['currentContentLayout'] = 'frontPage';
        } else if (is_post_type_archive('gallery') || is_tax('gallery-category') || is_tax('gallery-tag')) {
            $this->data['currentContentLayout'] = 'galleryArchive';
        } else if (is_post_type_archive('video') || is_tax('video-category') || is_tax('video-tag')) {
            $this->data['currentContentLayout'] = 'videoArchive';
        } else if (is_archive() || is_search() || (is_home() && !is_front_page())) {
            $this->data['currentContentLayout'] = 'postArchive';
            if (is_category('Trending')) {
                // Here I want to alter the query
            }
        } else if (is_page()) {
            $this->data['currentContentLayout'] = 'page';
        } else if (is_single()) {
            switch (get_post_type()) {
                case 'video':
                    $this->data['currentContentLayout'] = 'video';
                    break;
                case 'gallery':
                    $this->data['currentContentLayout'] = 'gallery';
                    break;
                default:
                    $this->data['currentContentLayout'] = 'post';
            }
        } else {
            exit;
        }
    }

0 个答案:

没有答案