Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.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 当';有存档';设置为true_Php_Wordpress_Archive_Custom Post Type - Fatal编程技术网

Php 当';有存档';设置为true

Php 当';有存档';设置为true,php,wordpress,archive,custom-post-type,Php,Wordpress,Archive,Custom Post Type,我的网站上有3种帖子类型。2是自定义的帖子类型。我在主索引页上创建了3个独立的循环,并使用此代码查询了2篇自定义文章 <?php query_posts(array( 'post_type' => 'events', 'showposts' => 10 ) ); ?> 我正在使用自定义帖子类型UI插件,但当我将“has archive”选项更改为true时,我的一个自定义帖子类型将从主索引页中消失。因此,假设

我的网站上有3种帖子类型。2是自定义的帖子类型。我在主索引页上创建了3个独立的循环,并使用此代码查询了2篇自定义文章

<?php 
    query_posts(array( 
        'post_type' => 'events',
        'showposts' => 10 
    ) );  
?>

我正在使用自定义帖子类型UI插件,但当我将“has archive”选项更改为true时,我的一个自定义帖子类型将从主索引页中消失。因此,假设自定义帖子类型“事件”的代码是第一个,而“书籍”的代码在下面,书籍自定义帖子类型就消失了,但是如果我将“has archive”选项更改为false,自定义帖子将从Wordpress Codex重新出现

query_posts()是一种过于简单且有问题的修改main的方法 通过将页面替换为查询的新实例进行查询。它是 效率低下(重新运行SQL查询),在某些情况下会彻底失败 情况(尤其是在处理帖子分页时)。 任何现代WP代码都应该使用更可靠的方法,比如 为了达到这一目的,我们准备了一个钩

这里有一篇好文章可以帮助你