Custom Post Formats for Custom Post Types

You have several options here so I will clarify what you can do. Create a custom post type template page using something like single-customposttype.php and take advantage of the template hierarchy, http://codex.wordpress.org/Template_Hierarchy Use a conditional query for your styling in the loop ( or whatever you’re using), along the line of if (post type= your … Read more

Why does a custom post type need the ”hierarchical’ args setting?

When you have two content objects with a similar interface or shared properties, you have a good candidate for hierarchical post types. Take places as an example (see this answer): Asia Europe Germany Berlin Austria Vienna Each place has similar meta data: population, geo coordinates, spoken languages. You just can reuse the same interface. Plus, … Read more

Get Custom post with ID

You simply don’t need to specify a post_type when calling get_post(). The ID for any sort of post is unique among the whole DB-posts table. So if you’re calling a post with ID = 17 $id = 17; $post = get_post( $id ); then you’ll simply get this single post. Note, according the Codex, when … Read more

How do i display the post type title?

You can write a general template tag for this task. function wpse60306_get_post_type( $echo = true ) { static $post_types, $labels=””; // Get all post type *names*, that are shown in the admin menu empty( $post_types ) AND $post_types = get_post_types( array( ‘show_in_menu’ => true, ‘_builtin’ => false, ), ‘objects’ ); empty( $labels ) AND $labels … Read more

Have different search results template depending of custom post type searched

So I have found the solution, I leave it here if anyone needs something like this in the future. On your search form add a hidden field: <input type=”hidden” name=”post_type” value=”post_type_name” /> Then on your search.php file add the following WITHIN the loop: <?php if(isset($_GET[‘post_type’])) { $type = $_GET[‘post_type’]; if($type == ‘post_type_name_1’) {?> <!–Your Code … Read more

Custom Post Type menu name

When you register your custom post type there’s an argument called ‘labels’ you can pass to register_post_type(). The argument is an associative array with named labels for the menu and screens of your post type. Specifically, the label you are looking for is called ‘all_items’. I don’t know your code for registering the post type, … Read more