Advertisement
Guest User

Featured Image - GF

a guest
Mar 6th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. // http://www.gravityhelp.com/forums/topic/display-featured-image-selection-based-on-conditional-logic#post-161066
  2. // change the 98 here to your form ID
  3. add_action('gform_after_submission_5', 'set_featured_image', 10, 2);
  4. function set_featured_image($entry, $form){
  5. // change $entry['2'] to the field where the radio button
  6. // image was selected mine was field 2. The value of that
  7. // radio button should be the attachment ID
  8. set_post_thumbnail($entry['post_id'], $entry['14']);
  9.  
  10.  
  11. // Loop through categories assigned to the post and link images to the category archive page
  12.  
  13. $categories = get_categories();
  14. foreach ($categories as $category) :
  15. query_posts('cat='.$category->cat_ID);
  16. while(have_posts()){
  17. the_post();
  18. ?>
  19. <!-- begin post -->
  20. <li>
  21. <a href="<?php echo get_category_link($category->cat_ID); ?>"> <?php
  22. if ( set_post_thumbnail($entry['post_id'], $entry['14'])){
  23.  
  24. the_post_thumbnail( );
  25. } else { ?>
  26.  
  27. <img src="<?php bloginfo('template_url'); ?>/images/cfc7cf.png">
  28. <?php }
  29.  
  30.  
  31. ?>
  32. </a>
  33.  
  34. </li>
  35. <!-- end post -->
  36. <?php }
  37. endforeach;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement