Question

I am working on a wordpress project in a child theme of "Twenty Thirteen" main theme.

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:

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.

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();
Was it helpful?

Solution

Never, ever forget to put this line in your loop:

$custom_query->the_post();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top