| | 15 | * Creates the initial post types when 'init' action is fired. |
| | 16 | */ |
| | 17 | function create_initial_post_types() { |
| | 18 | register_post_type( 'post', array('exclude_from_search' => false) ); |
| | 19 | register_post_type( 'page', array('exclude_from_search' => false) ); |
| | 20 | register_post_type( 'attachment', array('exclude_from_search' => false) ); |
| | 21 | register_post_type( 'revision', array('exclude_from_search' => true) ); |
| | 22 | } |
| | 23 | add_action( 'init', 'create_initial_post_types', 0 ); // highest priority |
| | 24 | |
| | 25 | /** |
| | 426 | * Register a post type. Do not use before init. |
| | 427 | * |
| | 428 | * A simple function for creating or modifying a post type based on the |
| | 429 | * parameters given. The function will accept an array (second optional |
| | 430 | * parameter), along with a string for the post type name. |
| | 431 | * |
| | 432 | * |
| | 433 | * Optional $args contents: |
| | 434 | * |
| | 435 | * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true. |
| | 436 | * |
| | 437 | * @package WordPress |
| | 438 | * @subpackage Post |
| | 439 | * @since 2.9.0 |
| | 440 | * @uses $wp_post_types Inserts new post type object into the list |
| | 441 | * |
| | 442 | * @param string $post_type Name of the post type. |
| | 443 | * @param array|string $args See above description. |
| | 444 | */ |
| | 445 | function register_post_type($post_type, $args = array()) { |
| | 446 | global $wp_post_types; |
| | 447 | |
| | 448 | if (!is_array($wp_post_types)) |
| | 449 | $wp_post_types = array(); |
| | 450 | |
| | 451 | $defaults = array('exclude_from_search' => true); |
| | 452 | $args = wp_parse_args($args, $defaults); |
| | 453 | |
| | 454 | $post_type = sanitize_user($post_type, true); |
| | 455 | $args['name'] = $post_type; |
| | 456 | $wp_post_types[$post_type] = (object) $args; |
| | 457 | } |
| | 458 | |
| | 459 | /** |