Advertisement
Guest User

Functions to Setup Slideshow

a guest
Sep 22nd, 2010
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 KB | None | 0 0
  1. // slideshow Pagination
  2. add_action( 'the_post', 'paginate_slide' );
  3.  
  4. function paginate_slide( $post ) {
  5.  
  6.     global $pages, $multipage, $numpages;
  7.  
  8.     if( is_single() && get_post_type() == 'lom_slideshow' ) {
  9.  
  10.     $multipage = 1;
  11.     $id = get_the_ID();
  12.     $custom = array();
  13.     $pages = array();
  14.     $i = 1;
  15.  
  16.     foreach( get_post_custom_keys() as $key )
  17.         if ( false !== strpos( $key, 'slide' ) )
  18.             $custom[$key] = get_post_meta( $id, $key, true);
  19.  
  20.     while( isset( $custom["slide{$i}-title"] ) ) {
  21.    
  22.     $hide = $custom["slide{$i}-hide"];
  23. if( 'checkbox_on' == $hide ) {
  24.     $i++;
  25.     continue;
  26. }
  27.         $page = '';
  28.         $title = $custom["slide{$i}-title"];
  29.         $image = $custom["slide{$i}-image"];
  30.         $desc = $custom["slide{$i}-desc"];
  31.         $embed = $custom["slide{$i}-embed"];
  32.         $page = "<div class='media-title'><h2>{$title}</h2></div>{$numpages}<div class='media-image'><img src='{$image}' />{$embed}</div><div class='media-desc'>{$desc}</div>";
  33.         $pages[] = $page;
  34.         $i++;
  35.     }
  36.     $numpages = count( $pages );
  37.     }
  38. }
  39.  
  40. // Apply the Custom Post Type Template
  41. function post_type_add_template() {
  42.  $post_type = get_query_var('post_type');
  43.  if (!empty($post_type)) {
  44.   locate_template(array("{$post_type}.php","single.php"), true);
  45.   exit;
  46.  }
  47. }
  48. add_action('template_redirect', 'post_type_add_template');
  49.  
  50. // Custom Post Types:
  51. add_action( 'init', 'create_my_post_types' );
  52.  
  53. function create_my_post_types() {
  54.         register_post_type( 'lom_slideshow',
  55.         array(
  56.             'labels' => array(
  57.                 'name' => __( 'Slideshows' ),
  58.                 'singular_name' => __( 'Slideshow' ),
  59.                 'add_new' => __( 'Add New' ),
  60.                 'add_new_item' => __( 'Add New Slideshow' ),
  61.                 'edit' => __( 'Edit' ),
  62.                 'edit_item' => __( 'Edit Slideshow' ),
  63.                 'new_item' => __( 'New Slideshow' ),
  64.                 'view' => __( 'View Slideshow' ),
  65.                 'view_item' => __( 'View Slideshow' ),
  66.                 'search_items' => __( 'Search Slideshow' ),
  67.                 'not_found' => __( 'No slideshows found' ),
  68.                 'not_found_in_trash' => __( 'No slideshows found in Trash' )
  69.             ),
  70.             'public' => true,
  71.             'menu_position' => 5,
  72.             'hierarchical' => true,
  73.             'query_var' => true,
  74.             //Once I figure these metaboxes out I will remove 'custom-fields'
  75.             'supports' => array( 'title', 'author', 'excerpt', 'trackbacks', 'custom-fields', 'thumbnail', 'comments', 'revisions', 'page-attributes' ),
  76.             'rewrite' => array( 'slug' => 'multimedia/slideshows', 'with_front' => true ),
  77.             'taxonomies' => array( 'post_tag', 'category', 'multimedia'),
  78.             'can_export' => true,
  79.  
  80.         )
  81.     );
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement