Wednesday, 4 June 2014

Create testimonial custome function in wordpress

IN function.php

add_action('init', 'Testimonial');

function Testimonial() {

    $labels = array(
 'name' => _x('Testimonial', 'post type general name'),


'singular_name' => _x('Testimonial Item', 'post type singular name'),
        'add_new' => _x('Add New', 'Testimonial item'),
        'add_new_item' => __('Add New Testimonial Item'),
        'edit_item' => __('Edit Testimonial Item'),
        'new_item' => __('New Testimonial Item'),
        'view_item' => __('View Testimonial Item'),
        'search_items' => __('Search Testimonial'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'menu_icon' => admin_url(). 'images/testimonial.png',
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail')
      );

    register_post_type( 'Testimonial' , $args );
}



In  front page you want to show testimonial

<div class="testimonial">
            <div class="testimonial_text">
                <span class="bottom_arrow"></span>
                <?php query_posts(array('showposts' => 1,'post_type' => 'Testimonial')); while (have_posts()) { the_post();
                    $pimage = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
                    ?>
                    <p><span><img src="<?php echo bloginfo('template_directory'); ?>/images/quot_img.png" alt="quot"></span><?php the_content(); ?> </p>
                    <?php } ?>
            </div>
            <div class="client_detail">
                <h4><strong>Pat Richie, Principal Consultant</strong><br>Table Group Consulting,</h4>
                <figure><img src="<?php echo bloginfo('template_directory'); ?>/images/client_img.png" alt="Client_1"></figure>
            </div>
        </div>

No comments :

Post a Comment