Advertisement
Digitalraindrops

adventure child functions.php

Feb 29th, 2012
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2. /* Child Theme function by Digital Raindrops */
  3. function raindrops_get_category_image() {
  4.     if ( is_category() ) {
  5.         //Get the active category id
  6.         global $cat;
  7.         if( $cat ) {  
  8.             //Find the ID of the first post in the category
  9.             $args = array( 'numberposts' => -1, 'category' => $cat, 'order'=> 'ASC', 'post_status' => 'publish' );
  10.             $myposts = get_posts( $args );
  11.             foreach( $myposts as $catpost ) {
  12.                 if ( has_post_thumbnail( $catpost->ID ) ) {
  13.                     $url = wp_get_attachment_image_src( get_post_thumbnail_id( $catpost->ID ), 'single-post-thumbnail' );              
  14.                     $path = $url[0];
  15.                     return  esc_url_raw( $url[0] );
  16.                 }
  17.             }
  18.             return ''; 
  19.         }  
  20.     }
  21.     return '';
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement