Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // slideshow Pagination
- add_action( 'the_post', 'paginate_slide' );
- function paginate_slide( $post ) {
- global $pages, $multipage, $numpages;
- if( is_single() && get_post_type() == 'lom_slideshow' ) {
- $multipage = 1;
- $id = get_the_ID();
- $custom = array();
- $pages = array();
- $i = 1;
- foreach( get_post_custom_keys() as $key )
- if ( false !== strpos( $key, 'slide' ) )
- $custom[$key] = get_post_meta( $id, $key, true);
- while( isset( $custom["slide{$i}-title"] ) ) {
- $hide = $custom["slide{$i}-hide"];
- if( 'checkbox_on' == $hide ) {
- $i++;
- continue;
- }
- $page = '';
- $title = $custom["slide{$i}-title"];
- $image = $custom["slide{$i}-image"];
- $desc = $custom["slide{$i}-desc"];
- $embed = $custom["slide{$i}-embed"];
- $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>";
- $pages[] = $page;
- $i++;
- }
- $numpages = count( $pages );
- }
- }
- // Apply the Custom Post Type Template
- function post_type_add_template() {
- $post_type = get_query_var('post_type');
- if (!empty($post_type)) {
- locate_template(array("{$post_type}.php","single.php"), true);
- exit;
- }
- }
- add_action('template_redirect', 'post_type_add_template');
- // Custom Post Types:
- add_action( 'init', 'create_my_post_types' );
- function create_my_post_types() {
- register_post_type( 'lom_slideshow',
- array(
- 'labels' => array(
- 'name' => __( 'Slideshows' ),
- 'singular_name' => __( 'Slideshow' ),
- 'add_new' => __( 'Add New' ),
- 'add_new_item' => __( 'Add New Slideshow' ),
- 'edit' => __( 'Edit' ),
- 'edit_item' => __( 'Edit Slideshow' ),
- 'new_item' => __( 'New Slideshow' ),
- 'view' => __( 'View Slideshow' ),
- 'view_item' => __( 'View Slideshow' ),
- 'search_items' => __( 'Search Slideshow' ),
- 'not_found' => __( 'No slideshows found' ),
- 'not_found_in_trash' => __( 'No slideshows found in Trash' )
- ),
- 'public' => true,
- 'menu_position' => 5,
- 'hierarchical' => true,
- 'query_var' => true,
- //Once I figure these metaboxes out I will remove 'custom-fields'
- 'supports' => array( 'title', 'author', 'excerpt', 'trackbacks', 'custom-fields', 'thumbnail', 'comments', 'revisions', 'page-attributes' ),
- 'rewrite' => array( 'slug' => 'multimedia/slideshows', 'with_front' => true ),
- 'taxonomies' => array( 'post_tag', 'category', 'multimedia'),
- 'can_export' => true,
- )
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement