
Untitled
By: a guest on
Sep 13th, 2012 | syntax:
None | size: 1.19 KB | hits: 10 | expires: Never
<?php
/**
* Sets up the theme by loading the Mysitemyway class & initializing the framework
* which activates all classes and functions needed for theme's operation.
*
* @package Mysitemyway
* @subpackage Functions
*/
<?php
// update the "4" to the ID of your form
add_filter("gform_post_submission_4", "gform_set_post_thumbnail");
function gform_set_post_thumbnail($entry){
// get post ID of the created post
$post_id = $entry["post_id"];
// get the last image added to the post
$attachments = get_posts(array('numberposts' => '1', 'post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC'));
if(sizeof($attachments) == 0)
return; //no images attached to the post
// set image as the post thumbnail
set_post_thumbnail($post_id, $attachments[0]->ID);
}
# Load the Mysitemyway class.
require_once( TEMPLATEPATH . '/framework.php' );
# Get theme data.
$theme_data = get_theme_data( TEMPLATEPATH . '/style.css' );
# Initialize the Mysitemyway framework.
Mysitemyway::init(array(
'theme_name' => $theme_data['Name'],
'theme_version' => $theme_data['Version']
));
?>