Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*--------------------------------------------------------------
- ## Register Custom Post Type
- --------------------------------------------------------------*/
- function ad_register_jobs_post_type() {
- $singular = 'Service';
- $plural = 'Services';
- $labels = array(
- 'name' => $plural,
- 'singular_name' => $singular,
- 'menu_name' => $plural,
- 'name_admin_bar' => $plural,
- 'archives' => $singular . ' Archives',
- 'parent_item_colon' => $singular,
- 'all_items' => $plural,
- 'add_new_item' => 'Add ' . $singular,
- 'add_new' => 'Add ' . $singular,
- 'new_item' => 'New ' . $singular,
- 'edit_item' => 'Edit ' . $singular,
- 'update_item' => 'Update ' . $singular,
- 'view_item' => 'View ' . $singular,
- 'search_items' => 'Search ' . $plural,
- 'not_found' => 'No ' . $plural . ' Found',
- 'not_found_in_trash' => 'No ' . $plural . ' Found In Trash',
- 'featured_image' => __( 'Featured Image', 'text_domain' ),
- 'set_featured_image' => __( 'Set Featured Image', 'text_domain' ),
- 'remove_featured_image' => __( 'Remove Featured Image', 'text_domain' ),
- 'use_featured_image' => __( 'Use as Featured Image', 'text_domain' ),
- 'insert_into_item' => 'Insert into ' . $singular,
- 'uploaded_to_this_item' => 'Uploaded to this ' . $singular,
- 'items_list' => $singular . ' List',
- 'items_list_navigation' => $singular . ' List Navigation',
- 'filter_items_list' => 'Filter ' . $singular . ' List',
- );
- $rewrite = array(
- 'slug' => 'services',
- 'with_front' => false,
- 'pages' => true,
- 'feeds' => false,
- );
- $capabilities = array(
- 'edit_post' => 'edit_service',
- 'read_post' => 'read_service',
- 'delete_post' => 'delete_service',
- 'edit_posts' => 'edit_services',
- 'edit_others_posts' => 'edit_others_services',
- 'publish_posts' => 'publish_services',
- 'read_private_posts' => 'read_private_services',
- 'create_posts' => 'edit_services',
- );
- $company = 'Calm Trees Printing ';
- $args = array(
- 'label' => $plural,
- 'description' => $company . $plural,
- 'labels' => $labels,
- 'supports' => array( 'title', 'thumbnail', 'editor' ),
- // 'taxonomies' => array( 'category', 'post_tag' ),
- 'hierarchical' => false,
- 'public' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'menu_position' => 5,
- 'menu_icon' => 'dashicons-screenoptions',
- 'show_in_admin_bar' => true,
- 'show_in_nav_menus' => true,
- 'can_export' => true,
- 'has_archive' => false,
- 'exclude_from_search' => true,
- 'publicly_queryable' => true,
- // 'query_var' => 'links',
- 'capability_type' => 'post',
- 'rewrite' => $rewrite,
- // 'capabilities' => $capabilities,
- );
- register_post_type( 'ctp_services', $args );
- }
- add_action( 'init', 'ad_register_jobs_post_type', 0 );
- /*--------------------------------------------------------------
- ## Home Page
- --------------------------------------------------------------*/
- function ctp_services() {
- $args = array(
- 'post_type' => 'ctp_services',
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- // 'orderby' => 'rand',
- 'order' => 'ASC',
- );
- $services = new WP_Query( $args );
- if ( $services->have_posts() ) :
- $html_out = '';
- $html_out .= '<section class="services">';
- $html_out .= '<div class="container">';
- $html_out .= '<div class="row">';
- // $html_out .= '<div class="ctp-col col-xs-10">';
- while ($services->have_posts()) : $services->the_post();
- $title = get_the_title();
- $content = apply_filters( 'the_content', get_the_content() );
- $link = get_the_permalink();
- $icon = get_field('service_icon');
- // Output Services Here
- $html_out .= '<div class="service-col">'; //col-xs-12 col-sm-4 col-md-2
- if( $title ):
- $html_out .= '<a href="' . $link . '">';
- $html_out .='<div class="service-item">';
- if( $icon ):
- $html_out .= '<div class="service-icon">';
- $html_out .= '<img src="' . $icon . '" alt="' . $title . '" class="style-svg" />';
- $html_out .= '</div>'; // service-icon
- endif;
- $html_out .= '<h4>' . $title . '</h4>';
- // $html_out .= $content;
- $html_out .= '</div>'; // service-item
- $html_out .= '</a>';
- endif;
- $html_out .= '</div>'; // service-col
- endwhile;
- // $html_out .= '</div>'; // col
- $html_out .= '</div>'; // row
- $html_out .= '</div>'; // service-type
- $html_out .= '</section>'; // services
- else : // No results
- $html_out = "No Services Found.";
- endif;
- wp_reset_postdata();
- return $html_out;
- }
- add_shortcode('all_services', 'ctp_services');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement