- This topic has 16 replies, 3 voices, and was last updated 5 years, 4 months ago by Tom.
-
AuthorPosts
-
November 12, 2018 at 2:13 pm #725674Margot
Hi there,
I’m having issues where my Media Library is only partially loading images that have been uploaded. Some images are present but others have disappeared. When I switch to a different theme the problem goes away. Please help. Thank you!
November 12, 2018 at 5:13 pm #725746LeoStaffCustomer SupportHi there,
Can you try #1 here to eliminate any plugin conflicts first?
https://docs.generatepress.com/article/debugging-tips/Let me know 🙂
November 12, 2018 at 5:42 pm #725761MargotI tested for plugin conflicts and also reinstalled the WordPress core files. Still experiencing issues.
November 12, 2018 at 6:26 pm #725771TomLead DeveloperLead DeveloperHi there,
The theme itself doesn’t have any control over the Media Library.
Does it happen with GP Premium activated as well?
Any visible errors? If not, any errors in your
error_log
file?November 13, 2018 at 4:43 am #726023MargotIt happens with GP Premium as well. I don’t see anything in the error_log.
I thought it might be my child theme causing the problem so switched to use only the parent theme and it has the same problem. If I switch to a default WordPress theme (i.e. Twenty Seventeen), the images from the Media Library load without issues.
November 13, 2018 at 7:32 am #726319TomLead DeveloperLead DeveloperCan you show me a screenshot of the problem?
November 13, 2018 at 8:09 am #726358MargotHere’s an example. Only 16 images show up in the media library and it doesn’t allow the library to show more than 16 images at a time, even when I’m using search function.
November 13, 2018 at 9:02 am #726415TomLead DeveloperLead DeveloperAnd there are more items than that? What if you click the list icon? (under the word “Media”)
November 13, 2018 at 9:12 am #726430MargotIf I click on the list icon it shows the full list of images (2,396 items). But if I go back to clicking the grid icon it only shows the most recent 16 images.
November 13, 2018 at 10:42 am #726513MargotHmm. One thing that’s standing out to me is that I have this snipped loaded in functions.php
I got it via this link > https://generatepress.com/forums/topic/blog-add-on-different-number-of-post-in-first-page-of-blog/#post-372928 :add_action( 'pre_get_posts', 'tu_change_posts_per_page', 1 ); function tu_change_posts_per_page( &$query ) { if ( ! is_main_query() ) { return; } if ( ! $query->is_paged ) { $query->set( 'posts_per_page', 16 ); } }
I added it so that the first page of the blog (as well as all first pages of blog archives like tag or blog category) only display 16 posts per page. But maybe it’s stopping other elements on the backend from loading. Could this be a cause in theory?
November 13, 2018 at 3:16 pm #726692TomLead DeveloperLead DeveloperYep, that’ll do it.
Try changing it to this:
add_action( 'pre_get_posts', 'tu_change_posts_per_page', 1 ); function tu_change_posts_per_page( &$query ) { if ( ! is_main_query() ) { return; } if ( is_admin() ) { return; } if ( ! $query->is_paged ) { $query->set( 'posts_per_page', 16 ); } }
November 13, 2018 at 4:29 pm #726730MargotThat worked. However, I’m worried that there may be a situation down the line where something else involving posts might end up getting hidden from viewers… Could this work if I wanted it only ever to affect the blog and blog archives?
add_action( 'pre_get_posts', 'tu_change_posts_per_page', 1 ); function tu_change_posts_per_page( &$query ) { if ( ! is_main_query() ) { return; } if ( (! $query->is_paged ) && (class_exists('archive')) || (! $query->is_paged ) && (class_exists('category'))) { $query->set( 'posts_per_page', 16 ); } }
November 13, 2018 at 6:19 pm #726757TomLead DeveloperLead DeveloperInstead of
class_exists
, dois_archive()
andis_category()
.November 14, 2018 at 9:53 am #727342MargotWould that be this?
add_action( 'pre_get_posts', 'tu_change_posts_per_page', 1 ); function tu_change_posts_per_page( &$query ) { if ( ! is_main_query() ) { return; } if ( (! $query->is_paged ) && (! $query->is_archive ) || (! $query->is_paged ) && (! $query->is_category )) { $query->set( 'posts_per_page', 16 ); } }
November 14, 2018 at 10:04 am #727346TomLead DeveloperLead DeveloperTry this:
add_action( 'pre_get_posts', 'tu_change_posts_per_page', 1 ); function tu_change_posts_per_page( &$query ) { if ( ! is_main_query() || is_admin() ) { return; } if ( ! $query->is_paged && ( $query->is_archive || $query->is_category ) ) { $query->set( 'posts_per_page', 16 ); } }
-
AuthorPosts
- You must be logged in to reply to this topic.