Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!------------------------------------Custom post Register and global and general query-------------------------------------------->
- <!---------------------------------custom Post Register-------------------------------------->
- /*Custom post query ==========================================================*/
- /* Register Custom Post Types********************************************/
- function create_post_type() {
- register_post_type( 'testimonial',/*You can set any name*/
- array(
- 'labels' => array(
- 'name' => __( 'Testimonial' ),/*You can set any name*/
- 'singular_name' => __( 'Testimonial' ),/*You can set any name*/
- 'add_new' => __( 'Add New' ),
- 'add_new_item' => __( 'Add New Testimonial' ),
- 'edit_item' => __( 'Edit Testimonial' ),
- 'new_item' => __( 'New Testimonial' ),
- 'view_item' => __( 'View Testimonial' ),
- 'not_found' => __( 'Sorry, we couldn\'t find the Testimonial you are looking for.' )
- ),
- 'public' => true,
- 'publicly_queryable' => false,
- 'exclude_from_search' => true,
- 'menu_position' => 14,
- 'has_archive' => false,
- 'hierarchical' => false,
- 'capability_type' => 'page',
- 'rewrite' => array( 'slug' => 'testimonial' ),/*You can set any name*/
- 'supports' => array( 'title', 'editor', 'custom-fields' )/*You can use another option here*/
- )
- );
- }
- add_action( 'init', 'create_post_type' );
- <!------------------------------------------------General Queries----------------------------------------------------->
- <?php query_posts('post_type=testimonial&post_status=publish&posts_per_page=10&paged='. get_query_var('paged')); ?>
- <!-------------------------------------------------Global Queries------------------------------------------------------>
- <?php
- global $post;
- $args = array( 'posts_per_page' => 4, 'post_type'=> 'slider-items');
- $myposts = get_posts( $args );
- foreach( $myposts as $post ) : setup_postdata($post); ?>
- <!-----------------------Past code which data actually dynamically shown----------------------------->
- <?php endforeach; ?>
- <!----------------------------Slider small Images dynamic code------------------------------------------->
- <?php $slider_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'small-image' ); ?>/*slider small images*/
- <li data-thumb="<?php echo $slider_image[0]; ?>">/*slider small images*/
- <?php the_post_thumbnail('large-image', array('class' => 'slider')); ?>/*slider big images*/
- <?php the_content();?>/*slider content*/
- </li>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement