繁体   English   中英

WP_Query在Wordpress子主题中

[英]WP_Query in a Wordpress child theme

我正在以“二十十三”为主题的儿童主题下的wordpress项目。

我的“页面模板”文件夹下有一个页面模板。

当我运行下面的代码时,一切正常。

$custom_query = new WP_Query();

但是,当我尝试通过这样的自定义帖子类型查询时:

$custom_query = new WP_Query( array('post_type' => 'myCustomType') );

我收到此错误:

Fatal error: Maximum execution time of 30 seconds exceeded in /opt/lampp/htdocs/sub_domain/wp-includes/class-wp-embed.php on line 283

这些是第282、283和284行:

function autoembed( $content ) {
    return preg_replace_callback( '|^\s*(https?://[^\s"]+)\s*$|im', array( $this, 'autoembed_callback' ), $content );
}

我正在使用WordPress版本3.8.1。

任何意见和答案表示赞赏。

编辑:完整版的循环

$custom_query = new WP_Query(  array('post_type' => 'myCustomType')  );

                // The Loop
                if ( $custom_query->have_posts() ) {
                    while ( $custom_query->have_posts() ) {
                        //something

                    }
                } else {
                    // no posts found
                }

                // Restore original Post Data
                wp_reset_postdata();

永远不要忘记将此行放入循环中:

$custom_query->the_post();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM