Skip to content

Instantly share code, notes, and snippets.

@claudioweb
Last active March 17, 2016 14:29
Show Gist options
  • Save claudioweb/8d53dbf9f47c47b79868 to your computer and use it in GitHub Desktop.
Save claudioweb/8d53dbf9f47c47b79868 to your computer and use it in GitHub Desktop.
Modificando Wordpress para criar post type e suas taxonomy...
/*===================================
= Posts Types =
===================================*/
/*========== Exemplo ==========*/
function exemplo() {
$args = array(
'labels' => array('name' => 'exemplo', 'add_new' => 'Adicionar'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'exclude_from_search' => true,
'rewrite' => array( 'slug' => 'exemplo' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'taxonomies' => array('categoria-exemplo'),
'menu_position' => 2,
'supports' => array( 'title', 'editor', 'tags', 'author', 'revisions', 'excerpt', 'comments', 'page-attributes' )
);
register_post_type( 'exemplo', $args );
flush_rewrite_rules();
}
add_action( 'init', 'exemplo' );
$args = array(
'hierarchical' => true,
//'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'categoria-exemplo' ),
'exclude_from_search' => false,
'publicly_queryable' => true,
'public' => true,
);
register_taxonomy( 'categoria-exemplo', 'exemplo', $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment