Advertisement
asadsuman

Custom Post,Custom post Query,Dynamic small and big images

Mar 20th, 2014
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. <!------------------------------------Custom post Register and global and general query-------------------------------------------->
  2. <!---------------------------------custom Post Register-------------------------------------->
  3. /*Custom post query ==========================================================*/
  4. /* Register Custom Post Types********************************************/
  5. function create_post_type() {
  6. register_post_type( 'testimonial',/*You can set any name*/
  7. array(
  8. 'labels' => array(
  9. 'name' => __( 'Testimonial' ),/*You can set any name*/
  10. 'singular_name' => __( 'Testimonial' ),/*You can set any name*/
  11. 'add_new' => __( 'Add New' ),
  12. 'add_new_item' => __( 'Add New Testimonial' ),
  13. 'edit_item' => __( 'Edit Testimonial' ),
  14. 'new_item' => __( 'New Testimonial' ),
  15. 'view_item' => __( 'View Testimonial' ),
  16. 'not_found' => __( 'Sorry, we couldn\'t find the Testimonial you are looking for.' )
  17. ),
  18. 'public' => true,
  19. 'publicly_queryable' => false,
  20. 'exclude_from_search' => true,
  21. 'menu_position' => 14,
  22. 'has_archive' => false,
  23. 'hierarchical' => false,
  24. 'capability_type' => 'page',
  25. 'rewrite' => array( 'slug' => 'testimonial' ),/*You can set any name*/
  26. 'supports' => array( 'title', 'editor', 'custom-fields' )/*You can use another option here*/
  27. )
  28. );
  29. }
  30. add_action( 'init', 'create_post_type' );
  31. <!------------------------------------------------General Queries----------------------------------------------------->
  32. <?php query_posts('post_type=testimonial&post_status=publish&posts_per_page=10&paged='. get_query_var('paged')); ?>
  33. <!-------------------------------------------------Global Queries------------------------------------------------------>
  34. <?php
  35. global $post;
  36. $args = array( 'posts_per_page' => 4, 'post_type'=> 'slider-items');
  37. $myposts = get_posts( $args );
  38. foreach( $myposts as $post ) : setup_postdata($post); ?>
  39.  
  40. <!-----------------------Past code which data actually dynamically shown----------------------------->
  41. <?php endforeach; ?>
  42. <!----------------------------Slider small Images dynamic code------------------------------------------->
  43. <?php $slider_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'small-image' ); ?>/*slider small images*/
  44. <li data-thumb="<?php echo $slider_image[0]; ?>">/*slider small images*/
  45. <?php the_post_thumbnail('large-image', array('class' => 'slider')); ?>/*slider big images*/
  46. <?php the_content();?>/*slider content*/
  47. </li>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement