簡體   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