/** * Displays the post's featured image, with link to post if is_single() is false. * @param string $size default: large * @return null */ function scoutwp_the_thumbnail($size = 'large') { if (!has_post_thumbnail()) { return; } global $wp_query; // tell responsive images what our sizes are if (is_media_post_format_archive($wp_query)) { add_filter('wp_get_attachment_image_attributes', 'scoutwp_filter_media_archive_thumbnail_sizes', -1, 3); } if (is_single()) { the_post_thumbnail($size); } else { ?> <a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?> "> <?php the_post_thumbnail($size); ?> </a> <?php } if (is_media_post_format_archive($wp_query)) { remove_filter('wp_get_attachment_image_attributes', 'scoutwp_filter_media_archive_thumbnail_sizes', -1); } }
/** * Pre query modifications * Alters posts_per_page for media archives * Sets single category for home page if option set in Customizer * @param object $query Current query object * @return null */ function scoutwp_pre_get_posts($query) { // if its a post format and a media type if (is_media_post_format_archive($query)) { $query->set('posts_per_page', get_theme_mod('media_per_archive', 15)); } if (scoutwp_is_site_index()) { if ($query->is_main_query() && get_theme_mod('fp_category', 0) != 0) { $query->set('cat', get_theme_mod('fp_category', 0)); } // modify query for single category } }