Advertisement
alaminlink

WP Theme Development (Custom Category Post Query & Register

Sep 18th, 2014
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. /* Register Custom Post Types********************************************/
  2.  
  3.     add_action( 'init', 'create_post_type' );
  4.     function create_post_type() {
  5.         register_post_type( 'testimonial',
  6.             array(
  7.                 'labels' => array(
  8.                     'name' => __( 'Testimonial' ),
  9.                     'singular_name' => __( 'Testimonial' ),
  10.                     'add_new' => __( 'Add New' ),
  11.                     'add_new_item' => __( 'Add New Testimonial' ),
  12.                     'edit_item' => __( 'Edit Testimonial' ),
  13.                     'new_item' => __( 'New Testimonial' ),
  14.                     'view_item' => __( 'View Testimonial' ),
  15.                     'not_found' => __( 'Sorry, we couldn\'t find the Testimonial you are looking for.' )
  16.                 ),
  17.             'public' => true,
  18.             'publicly_queryable' => false,
  19.             'exclude_from_search' => true,
  20.             'menu_position' => 14,
  21.             'has_archive' => false,
  22.             'hierarchical' => false,
  23.             'capability_type' => 'page',
  24.             'rewrite' => array( 'slug' => 'testimonial' ),
  25.             'supports' => array( 'title', 'editor', 'custom-fields' )
  26.             )
  27.         );
  28.     }
  29. Query Post from a specific category
  30.  
  31.  
  32.  
  33. <?php query_posts('post_type=post&post_status=publish&posts_per_page=10&paged='. get_query_var('paged')); ?>
  34.  
  35.  
  36.  
  37. Register Custom Post
  38.  
  39. Pastebin Code Link: http://pastebin.com/Fkgnu2KL
  40.  
  41.  
  42.  
  43. Query Custom Post List
  44.  
  45.  
  46.  
  47. <?php query_posts('post_type=testimonial&post_status=publish&posts_per_page=10&paged='. get_query_var('paged')); ?>
  48.  
  49.  
  50.  
  51. Query Custom Post Single
  52.  
  53.  
  54.  
  55. copy your single.php file & rename single-<custom-post>.php
  56.  
  57. <custom-post> = Custom Post Type
  58.  
  59.  
  60.  
  61. টিউটোরিয়াল লিংক: http://rrfoundation.net/365
  62.  
  63. সোর্স থিম ডাউনলোড: http://sdrv.ms/T4THqZ
  64.  
  65.  
  66.  
  67. পর্ব দুই এর
  68.  
  69.  
  70.  
  71. টিউটোরিয়াল লিংক: http://rrfoundation.net/369
  72.  
  73. সোর্স থিম ডাউনলোড: http://sdrv.ms/T4THqZ
  74. LikeLike ·
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement