Get the post children count of a post

class MyClass { … function post_count_filter($where) { global $wpdb; str_replace(“WHERE”, “WHERE “.$wpdb->posts.”.post_parent = “.$this->count_parent.” AND”, $where); return $where; } function count_children($post_id) { $this->count_parent = $post_id; add_filter(‘query’, ( &$this, ‘post_count_filter’) ); $stats = wp_count_posts(‘myposttype’); remove_filter(‘query’, ( &$this, ‘post_count_filter’) ); unset($this->count_parent); return array_sum( (array)$stats ); } // example of use function xyz() { global $post; … $child_count … Read more

Post type hierarchy

To me the most logical would be to have a “Book” custom post type, and then all the attributes of the books (Author, Collection, Genre, etc.) would be custom taxonomies. Then for your URLs you could use some custom URL rewrite method to get what you want.

Storing Custom Post Type Data in a Custom Table

You certainly can save the data however you choose using the save_post action. Simply, place this in your functions.php file. add_action(‘save_post’, ‘foo_save_custom_post_type’); function foo_save_custom_post_type(){ //Use the following debug code to see what information is available to you /* echo “<pre>”; print_r($_REQUEST); echo “</pre>”; exit; */ if(‘custom_post_type’ === $_REQUEST[‘post_type’]){ //Do your custom table bidding here } … Read more