Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // REGISTER CUSTOM POST TYPE
- function movies_functions() {
- $labels = array(
- 'name' => _x( 'Movies', 'Post Type General Name', 'text_domain' ),
- 'singular_name' => _x( 'Movie', 'Post Type Singular Name', 'text_domain' ),
- 'menu_name' => __( 'Movies', 'text_domain' ),
- 'parent_item_colon' => __( 'Parent Movie', 'text_domain' ),
- 'all_items' => __( 'All Movie', 'text_domain' ),
- 'view_item' => __( 'View Movie', 'text_domain' ),
- 'add_new_item' => __( 'Add New Movie', 'text_domain' ),
- 'add_new' => __( 'Add New', 'text_domain' ),
- 'edit_item' => __( 'Edit Movies', 'text_domain' ),
- 'update_item' => __( 'Update Movies', 'text_domain' ),
- 'search_items' => __( 'Search Movie', 'text_domain' ),
- 'not_found' => __( 'Not Found', 'text_domain' ),
- 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
- );
- $args = array(
- 'label' => __( 'movies_list', 'text_domain' ),
- 'description' => __( 'Movies news and reviews', 'text_domain' ),
- 'labels' => $labels,
- 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
- 'taxonomies' => array( 'genres' ),
- 'hierarchical' => false,
- 'public' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'show_in_nav_menus' => true,
- 'show_in_admin_bar' => true,
- 'menu_position' => 3,
- 'menu_icon' => 'dashicons-format-quote',
- 'can_export' => true,
- 'has_archive' => true,
- 'exclude_from_search' => false,
- 'publicly_queryable' => true,
- 'capability_type' => 'page',
- );
- register_post_type( 'movies_list', $args );
- // MovieS CATEGORY
- $labels = array(
- 'name' => _x( 'Movies Categories', 'taxonomy general name', 'textdomain' ),
- 'singular_name' => _x( 'Movie Category', 'taxonomy singular name', 'textdomain' ),
- 'search_items' => __( 'Search Movie Categories', 'textdomain' ),
- 'all_items' => __( 'All Movies Categories', 'textdomain' ),
- 'parent_item' => __( 'Parent Movies Category', 'textdomain' ),
- 'parent_item_colon' => __( 'Parent Movies Category:', 'textdomain' ),
- 'edit_item' => __( 'Edit Movies Category', 'textdomain' ),
- 'update_item' => __( 'Update Movies Category', 'textdomain' ),
- 'add_new_item' => __( 'Add New Movie Category', 'textdomain' ),
- 'new_item_name' => __( 'New Movie Category Name', 'textdomain' ),
- 'menu_name' => __( 'Movie Category', 'textdomain' ),
- );
- $args = array(
- 'hierarchical' => true,
- 'has_archive' => true,
- 'labels' => $labels,
- 'show_ui' => true,
- 'show_admin_column' => true,
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'movies_list_category' ),
- );
- register_taxonomy( 'movies_list_category', array( 'movies_list' ), $args );
- }
- add_action( 'init', 'movies_functions', 0 );
- // Drama
- function drama_function(){
- ob_start();
- $custom_query = new WP_Query(
- array(
- 'post_type' => 'movies_list',
- 'posts_per_page' => 9,
- 'order' => 'DESC',
- 'tax_query' => array(
- array(
- 'taxonomy' => 'movies_list_category',
- 'field' => 'slug',
- 'terms' => ( 'drama' ),
- )
- ),
- ) );
- if($custom_query->have_posts()) :
- while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
- <div class="gc-items">
- <?php if( have_rows('image_repeater') ): ?>
- <?php while( have_rows('image_repeater') ): the_row(); ?>
- <div class="gc-container">
- <div class="gc-content">
- <?php
- $image = get_sub_field('image_gallery');
- ?>
- <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
- </div>
- </div>
- <?php endwhile; ?>
- <?php endif; ?>
- </div>
- <?php
- endwhile;
- echo '</div></div>';
- endif;
- wp_reset_postdata();
- ?>
- <?php
- $content = ob_get_contents();
- ob_clean();
- return $content;
- }
- add_shortcode ( 'drama' , 'drama_function' );
- // Comedy function
- function comedy_function(){
- ob_start();
- $custom_query = new WP_Query(
- array(
- 'post_type' => 'movies_list',
- 'posts_per_page' => 9,
- 'order' => 'DESC',
- 'tax_query' => array(
- array(
- 'taxonomy' => 'movies_list_category',
- 'field' => 'slug',
- 'terms' => ( 'comedy' ),
- )
- ),
- ) );
- if($custom_query->have_posts()) :
- while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
- <div class="gc-items">
- <div class="gc-container">
- <div class="gc-content">
- <?php
- $postcontent = get_the_content();
- if ( !empty ($postcontent))
- {?>
- <h4><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></h4>
- <p> <?php echo $postcontent; ?></p>
- <?php }
- else
- { ?>
- <h4><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></h4>
- <p>Default content</p>
- <?php } ?>
- </div>
- </div>
- </div>
- <?php
- endwhile;
- endif;
- wp_reset_postdata();
- $content = ob_get_contents();
- ob_clean();
- return $content;
- }
- add_shortcode ( 'comedy' , 'comedy_function' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement