简体   繁体   English

WP_Query在Wordpress子主题中

[英]WP_Query in a Wordpress child theme

I am working on a wordpress project in a child theme of "Twenty Thirteen" main theme. 我正在以“二十十三”为主题的儿童主题下的wordpress项目。

I have a page template under my "page-templates" folder. 我的“页面模板”文件夹下有一个页面模板。

When I run the code below, everything works just fine. 当我运行下面的代码时,一切正常。

$custom_query = new WP_Query();

However, when I try to query through my custom post type like this: 但是,当我尝试通过这样的自定义帖子类型查询时:

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

I am getting this error: 我收到此错误:

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

And these are line 282, 283 and 284: 这些是第282、283和284行:

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

I am using WordPress version 3.8.1. 我正在使用WordPress版本3.8.1。

Any comment and answer is appreciated. 任何意见和答案表示赞赏。

EDIT: Full version of the loop 编辑:完整版的循环

$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