Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* create recent post ********************************************/
- function create_post_type() {
- register_post_type( 'services',
- array(
- 'labels' => array(
- 'name' => __( 'our services' ),
- 'singular_name' => __( 'our services' ),
- 'add_new' => __( 'Add New' ),
- 'add_new_item' => __( 'Add our service' ),
- 'edit_item' => __( 'Edit service' ),
- 'new_item' => __( 'New service' ),
- 'view_item' => __( 'View our service' ),
- 'not_found' => __( 'Sorry, we couldn\'t find the home our services you are looking for.' )
- ),
- 'public' => true,
- 'publicly_queryable' => true,
- 'exclude_from_search' => true,
- 'menu_position' => 14,
- 'has_archive' => true,
- 'hierarchical' => true,
- 'capability_type' => 'post',
- 'rewrite' => array( 'slug' => 'service' ),
- 'supports' => array( 'title', 'editor', 'thumbnail' )
- )
- );
- register_post_type( 'recent-works',
- array(
- 'labels' => array(
- 'name' => __( 'recent work' ),
- 'singular_name' => __( 'recent work' ),
- 'add_new' => __( 'Add New' ),
- 'add_new_item' => __( 'Add New recent work' ),
- 'edit_item' => __( 'Edit recent work' ),
- 'new_item' => __( 'New recent work' ),
- 'view_item' => __( 'View recent work' ),
- 'not_found' => __( 'Sorry, we couldn\'t find the recent works you are looking for.' )
- ),
- 'public' => true,
- 'publicly_queryable' => true,
- 'exclude_from_search' => true,
- 'menu_position' => 14,
- 'has_archive' => true,
- 'hierarchical' => true,
- 'capability_type' => 'post',
- 'rewrite' => array( 'slug' => 'recent-work' ),
- 'supports' => array( 'title', 'editor', 'thumbnail' )
- )
- );
- }
- add_action( 'init', 'create_post_type' );
- /************************sortcode register for recent works*********************************/
- function recent_works_post_shortcode($atts){
- extract( shortcode_atts( array(
- 'title' => '',
- 'category' => '',
- ), $atts, 'recent_works' ) );
- $q = new WP_Query(
- array( 'recent_works_cat' => $category, 'posts_per_page' => '4', 'post_type' => 'recent-works')
- );
- $list = '<h2 class="recent_header">'.$title.'</h2><div class="portfolio">';
- while($q->have_posts()) : $q->the_post();
- //get the ID of your post in the loop
- $id = get_the_ID();
- $portfolio_link = get_post_meta($id, 'portfolio_link', true);
- $post_thumbnail= get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
- $list .= '
- <div class="work col-md-3">
- '.$post_thumbnail.'
- <h4>'.get_the_title().'</h4>
- <p>'.get_the_content().'</p>
- <div class="icon-awesome">
- <a href="'. get_permalink() .'" rel="prettyPhoto"><i class="fa fa-search"></i></a>
- <a href="'.$portfolio_link.'" target="_blank"><i class="fa fa-link"></i></a>
- </div>
- </div>
- ';
- endwhile;
- $list.= '</div>';
- wp_reset_query();
- return $list;
- }
- add_shortcode('recent_works', 'recent_works_post_shortcode');
- /* recent_works_taxonomy ********************************************/
- function recent_works_taxonomy() {
- register_taxonomy(
- 'recent_works_cat', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
- 'recent-works', //post type name
- array(
- 'hierarchical' => true,
- 'label' => 'recent works Category', //Display name
- 'query_var' => true,
- 'show_admin_column' => true,
- 'rewrite' => array(
- 'slug' => 'recent-works-category', // This controls the base slug that will display before each term
- 'with_front' => false // Don't display the category base before
- )
- )
- );
- }
- add_action( 'init', 'recent_works_taxonomy');
- /************************sortcode register for our services *********************************/
- function our_services_shortcode($atts){
- extract( shortcode_atts( array(
- 'title' => '',
- 'category' => '',
- ), $atts, 'our_services' ) );
- $q = new WP_Query(
- array( 'our_services_cat' => $category, 'posts_per_page' => '6', 'post_type' => 'services')
- );
- $list = '<div class="service_list">';
- while($q->have_posts()) : $q->the_post();
- //get the ID of your post in the loop
- $id = get_the_ID();
- $service_icon = get_post_meta($id, 'service_icon', true);
- $list .= ' <div class="service col-md-4 col-sm-4">
- <h3>'. get_the_title() .'</h3>
- <div class="icon_holder_service">
- <a href="'. get_permalink() .'" ><i class="fa fa-'.$service_icon.'"></i></a>
- </div>
- <p>'.get_the_content().'</p>
- </div>
- ';
- endwhile;
- $list.= '</div>';
- wp_reset_query();
- return $list;
- }
- add_shortcode('our_services', 'our_services_shortcode');
- /* our_services_taxonomy ********************************************/
- function our_services_taxonomy() {
- register_taxonomy(
- 'our_services_cat', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
- 'services', //post type name
- array(
- 'hierarchical' => true,
- 'label' => 'our services Category', //Display name
- 'query_var' => true,
- 'show_admin_column' => true,
- 'rewrite' => array(
- 'slug' => 'service-category', // This controls the base slug that will display before each term
- 'with_front' => false // Don't display the category base before
- )
- )
- );
- }
- add_action( 'init', 'our_services_taxonomy');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement