Please use the experimental autocomplete fields with that amount of posts.
Hi, managed to get it working with 2000+ posts
I have optimized render_select() function in MslsMetaBox.php file, now it requires much less memory, the listing loop has been upgraded to:
$my_query = new WP_Query(
array(
'post_type' => $type,
'post_status' => get_post_stati( array( 'internal' => '' ) ),
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1,
'fields' => 'ids'
)
);
if ( $my_query->have_posts() )
foreach ($my_query->posts as $my_id) {
$options .= sprintf(
'<option value="%s" %s>%s</option>',
$my_id,
selected( $my_id, $mydata->$language, false ),
get_the_title($my_id)
);
}
Please include this upgrade to the next version, some credits would be appreciated as well 😉
Sorry but as I said before
Please use the experimental autocomplete fields with that amount of posts.
because I’m not sure if improving that part is a really great idea.
Please avoid to post code here if you like to contribute to the plugin. There is a repository at GitHub for this.
Cheers,
Dennis.
Your listing query was getting all the post fields and then preparing the post object for each listed item requiring huge amount of RAM if many posts are present, after my optimization the query just gets and array the post IDs, and then gets the title for each post ID which is cached by internal WordPress cache.
I estimate the memory requirements have been reduced 10 times if not more, also substantial increase in rendering speed 😉
Posted at GitHub as a proposed change.
This is my repository and there is no pull-request right now… did you fork the repository and did a pull-request too?
Here is the pull request, there are two suggestion, the first one is incomplete but I was unable to modify it, corrected with the second suggestion:
https://github.com/lloc/Multisite-Language-Switcher/pull/94
Ok, very good. I will accept this.