Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://www.gravityhelp.com/forums/topic/display-featured-image-selection-based-on-conditional-logic#post-161066
- // change the 98 here to your form ID
- add_action('gform_after_submission_5', 'set_featured_image', 10, 2);
- function set_featured_image($entry, $form){
- // change $entry['2'] to the field where the radio button
- // image was selected mine was field 2. The value of that
- // radio button should be the attachment ID
- set_post_thumbnail($entry['post_id'], $entry['14']);
- // Loop through categories assigned to the post and link images to the category archive page
- $categories = get_categories();
- foreach ($categories as $category) :
- query_posts('cat='.$category->cat_ID);
- while(have_posts()){
- the_post();
- ?>
- <!-- begin post -->
- <li>
- <a href="<?php echo get_category_link($category->cat_ID); ?>"> <?php
- if ( set_post_thumbnail($entry['post_id'], $entry['14'])){
- the_post_thumbnail( );
- } else { ?>
- <img src="<?php bloginfo('template_url'); ?>/images/cfc7cf.png">
- <?php }
- ?>
- </a>
- </li>
- <!-- end post -->
- <?php }
- endforeach;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement