for example in php when you read a file per line you can use fopen("inputfile.txt");
but this puts all lines in an array and cause memory error when the file is very big, an alternative to it is the fopen("inputfile.txt", "r");
and fgets();
you can read a file per line from disk, without loaded all to memory.
I was wondering if there is something similar with Wp query to searching the database 'slowly' without waiting to hit the memory limit even if the query is more slow to be done.
here is the query:
$arr = array();
$args = array(
'post_type' => 'post',
'order' => 'ASC',
'posts_per_page' => '-1',
);
$query = new WP_Query($args);
if($query->have_posts()):
while ($query->have_posts()) : $query->the_post();
if(get_post_meta( get_the_ID(),'slider_postition',true )!='None') {
$pos = get_field('slider_postition', get_the_ID());
$arr[$pos-1] = get_the_ID();
}
endwhile;
endif;
for($i = 0;$i<15;$i++) {
if($arr[$i] > 0) {
//output
}
}