Created
September 19, 2019 19:01
-
-
Save PareshRadadiya/5867c8929ab1ca72af5c2dc521bcdaa3 to your computer and use it in GitHub Desktop.
WP_Query with fields test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('init', 'test_wp_query'); | |
function test_wp_query() { | |
$time_start = microtime(true); | |
$query = new WP_Query([ | |
'nopaging' => true, | |
'post_type' => 'post', | |
'fields' => 'ids' | |
]); | |
if ( $query->have_posts() ) { | |
while( $query->have_posts()) { | |
$query->the_post(); | |
the_ID(); | |
} | |
} | |
$time_end = microtime(true); | |
//execution time of the script | |
echo '<b>Total Execution Time:</b> '.$time_end; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment