Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Child Theme function by Digital Raindrops */
- function raindrops_get_category_image() {
- if ( is_category() ) {
- //Get the active category id
- global $cat;
- if( $cat ) {
- //Find the ID of the first post in the category
- $args = array( 'numberposts' => -1, 'category' => $cat, 'order'=> 'ASC', 'post_status' => 'publish' );
- $myposts = get_posts( $args );
- foreach( $myposts as $catpost ) {
- if ( has_post_thumbnail( $catpost->ID ) ) {
- $url = wp_get_attachment_image_src( get_post_thumbnail_id( $catpost->ID ), 'single-post-thumbnail' );
- $path = $url[0];
- return esc_url_raw( $url[0] );
- }
- }
- return '';
- }
- }
- return '';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement