Thumbnails not displayed after pre_get_posts query
-
Hi all, I am creating an archive page on a custom post type, showing a list of works with title, description, author and thumbnail (fetured image), basically.
I had no problem and the archive page was successfully created.
MY only need was that the works displayed were not ordered by a custom fields “number” but by publishing date as default.
So I put this functions in my function.php (child theme).function cambia_ordine( $query ) { if ( $query->is_main_query() && !is_admin() ) { if ($query->is_post_type_archive('opera') ) { $query->set('orderby', 'meta_value_num'); $query->set('meta_key', 'numero'); $query->set('order', 'ASC'); } } } add_action( 'pre_get_posts', 'cambia_ordine' );
Hence the posts order was right, but all the thumbnails disappeared. If I delete the function “cambia_ordine”, thumbnails are visible again and obviously the order is wrong.
Could you please tell me why this happen? and how can I get the right order and thumnbnails displayed using pre_get_posts?
Many thanks in advance.
Claudio
- The topic ‘Thumbnails not displayed after pre_get_posts query’ is closed to new replies.