Your SlideShare is downloading. ×
0
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Extending WordPress. Making use of Custom Post Types

2,000

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,000
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Extending WordPress. Making use of Custom Post Types Utsav Singh @Rathour @codepixelzmedia http://codepixelz.com
  • 2. What is Custom Post Type?• A Custom Type is a Post Type you define.• Makes managing new content easier with already existing format for Post types.• They can represent any type of content you want.
  • 3. Inbuilt Default Post Types• There are some post types that are pre- defined, and they have been available since 2005. But have been in use widely since WordPress 3.0 was introduced.• Defatult Post Types: Posts, Pages, Revisions, Attachments, Menu Items
  • 4. Why use CPT?• Because just the feature that are bundled into WP that we see on the Dashboard does not make WP a complete CMS.• It helps in managing contents in a better way.
  • 5. Example• Products• Events• Movies• Real Estate• ……….
  • 6. How do you define CPT?• register_post_types()• Initialized using `init` hook. add_action( init, create_post_type ); function create_post_type() { register_post_type( product, array( labels => array( name => __( Products ), singular_name => __( Product ) ), public => true, has_archive => true, rewrite => array(slug => products) ) ); }
  • 7. How do you call a CPT?• Template Files – single-product.php – Archive-product.php *where product is a custom post type name.
  • 8. Query through CPT$args = array( post_type => product, posts_per_page => 10 );$loop = new WP_Query( $args );while ( $loop->have_posts() ) : $loop->the_post();the_title();echo <div class="entry-content">; the_content();echo </div>;endwhile;
  • 9. Custom Taxonomy (Category) for CPT• register_taxonomy(product_category, product, $args );
  • 10. Garnish using Custom Meta Box• You can also add different attributes to your newly created CPT by creating Custom Meta Box that intake the values such as Price, Weight, and so on….
  • 11. Thank You

×