#galleria{ width: 100%; height: 500px; background: #000; } "; } add_action('wp_head', '_sf_galleriaCSS'); /** * Setup galleria and data for it * *@since _sf-1.1.0 * *@params $default (required) first category in main dataset. Only on if $combine == false. *@params $cats (required) array of category IDs to create datasets for. NOT including the default category. *@params $combine (optional) (default = true). If set to true all data sets will be combined into one, big one, which will be default. *@params $switches (optional) (default = true) If set to true, will create the ability to switch categories via jQuery onClick("#switch-x") * *@params $desc, $link, false see _sf_galleria_data below * $combine = true, $switches = true, $title = false, $desc = false, $link = false */ add_action('wp_footer', '_sf_galleriaSetup', 10000); //*this should be gotten from options*/ $default = 5; $cats = array(8, 6); function _sf_galleriaSetup($default, $cats = array()) { $combine = true; /*Start and wrap script */ echo ""; } /** * Function to create the data sets. * *@since _sf-1.1.0 * *@params $CatID (required) ID of categories to create data sets for. *@params $title, $desc, $link (optional) (default false) If true add title (the_title()), description (the_excerpt()) and link (the_permalink()) to the datas /* $title = false, $desc = false, $link = false */ function _sf_galleria_data($CatID) { //setup before and after for data sets $startData = "var data".$CatID." = [ \n "; $endData = "]; \n"; //first start the data set echo $startData; //then get the posts in that are in the category and are image posts. $cat_posts = get_posts( array( 'cat' => $CatID, 'posts_per_page' => -1, 'nopaging' => true, ) ); //setup post data global $post; setup_postdata( $post ); //then loop through posts in the category putting together the data as needed. foreach( (array) $cat_posts as $post ) { //get all the shit we need together $ID = get_post_thumbnail_id(); $thumb = wp_get_attachment_image_src($ID); $full = wp_get_attachment_image_src($ID, 'full'); $large = wp_get_attachment_image_src($ID, 'large'); $title = get_the_title(); $desc = get_the_excerpt(); //Kirk: Prepare to echo. Sulu: Preparing to echo. $out = "{ \n "; $out .= "image: '".$large[0]."', \n "; $out .= "thumb: '".$thumb[0]."', \n "; $out .= "big: '".$full[0]."', \n "; $out .= "title: '".$title."', \n "; $out .= "description: '".$desc."', \n "; //$out .= "link: '".$link."', $out .= "}, \n "; //Kirk: ECHO! echo $out; } //then end the data set. echo $endData; //then reset post data wp_reset_postdata(); }