added custom post Resources and custom type of resource
This commit is contained in:
parent
aaf8d93f5b
commit
32629a052d
|
@ -29,7 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Register Custom Post Type
|
// Register Custom Post Type
|
||||||
function archive_wpplugin_custom_post_resource() {
|
function archive_wpplugin_init_custom_post_resource() {
|
||||||
|
|
||||||
$labels = array(
|
$labels = array(
|
||||||
'name' => _x( 'All resources', 'Post Type General Name', 'text_domain' ),
|
'name' => _x( 'All resources', 'Post Type General Name', 'text_domain' ),
|
||||||
|
@ -47,23 +47,23 @@ function archive_wpplugin_custom_post_resource() {
|
||||||
'not_found_in_trash' => __( 'We couldn\'t find any resource in the bin', 'text_domain' ),
|
'not_found_in_trash' => __( 'We couldn\'t find any resource in the bin', 'text_domain' ),
|
||||||
);
|
);
|
||||||
$rewrite = array(
|
$rewrite = array(
|
||||||
'slug' => 'resources/%archive_wpplugin_resource_type%',
|
'slug' => 'resources/%archive_resourcetype%',
|
||||||
'with_front' => true,
|
'with_front' => true,
|
||||||
'hierarchical' => true,
|
'hierarchical' => true,
|
||||||
);
|
);
|
||||||
$args = array(
|
$args = array(
|
||||||
'label' => __( 'archive_wpplugin_resource', 'text_domain' ),
|
'label' => __( 'archive_resource', 'text_domain' ),
|
||||||
'description' => __( 'Resources arcHIVE', 'text_domain' ),
|
'description' => __( 'Resources', 'text_domain' ),
|
||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
'supports' => array( 'title', 'editor', 'thumbnail', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes' ),
|
'supports' => array( 'title', 'editor', 'thumbnail', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes' ),
|
||||||
'taxonomies' => array('category','post_tag','archive_wpplugin_resource_type'),
|
'taxonomies' => array('category','post_tag','archive_resourcetype'),
|
||||||
'hierarchical' => true,
|
'hierarchical' => true,
|
||||||
'public' => true,
|
'public' => true,
|
||||||
'show_ui' => true,
|
'show_ui' => true,
|
||||||
'show_in_menu' => true,
|
'show_in_menu' => true,
|
||||||
'show_in_nav_menus' => true,
|
'show_in_nav_menus' => true,
|
||||||
'show_in_admin_bar' => true,
|
'show_in_admin_bar' => true,
|
||||||
'menu_position' => 5,
|
'menu_position' => 15,
|
||||||
'menu_icon' => 'dashicons-book',
|
'menu_icon' => 'dashicons-book',
|
||||||
'can_export' => true,
|
'can_export' => true,
|
||||||
'has_archive' => 'resources',
|
'has_archive' => 'resources',
|
||||||
|
@ -72,12 +72,13 @@ function archive_wpplugin_custom_post_resource() {
|
||||||
'capability_type' => 'post',
|
'capability_type' => 'post',
|
||||||
'rewrite' => $rewrite,
|
'rewrite' => $rewrite,
|
||||||
);
|
);
|
||||||
register_post_type( 'archive_wpplugin_resource', $args );
|
register_post_type( 'archive_resource', $args );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook into the 'init' action
|
// Hook into the 'init' action
|
||||||
add_action( 'init', 'archive_wpplugin_custom_post_resource', 0 );
|
add_action( 'init', 'archive_wpplugin_init_custom_post_resource', 0 );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start custom taxonomies
|
* Start custom taxonomies
|
||||||
|
@ -86,24 +87,24 @@ add_action( 'init', 'archive_wpplugin_custom_post_resource', 0 );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Register Custom Taxonomy
|
// Register Custom Taxonomy
|
||||||
function archive_wpplugin_custom_taxonomy_resource() {
|
function archive_wpplugin_register_taxonomy_resource() {
|
||||||
|
|
||||||
$labels = array(
|
$labels = array(
|
||||||
'name' => _x( 'Type of resources arcHIVE', 'Taxonomy General Name', 'text_domain' ),
|
'name' => _x( 'Type of resources', 'Taxonomy General Name', 'text_domain' ),
|
||||||
'singular_name' => _x( 'Type of resource arcHIVE', 'Taxonomy Singular Name', 'text_domain' ),
|
'singular_name' => _x( 'Type of resource', 'Taxonomy Singular Name', 'text_domain' ),
|
||||||
'menu_name' => __( 'Type resources arcHIVE', 'text_domain' ),
|
'menu_name' => __( 'Type resources', 'text_domain' ),
|
||||||
'all_items' => __( 'All type resources arcHIVE', 'text_domain' ),
|
'all_items' => __( 'All type resources', 'text_domain' ),
|
||||||
'parent_item' => __( 'Parent type resource arcHIVE', 'text_domain' ),
|
'parent_item' => __( 'Parent type resource', 'text_domain' ),
|
||||||
'parent_item_colon' => __( 'Parent type resource arcHIVE:', 'text_domain' ),
|
'parent_item_colon' => __( 'Parent type resource:', 'text_domain' ),
|
||||||
'new_item_name' => __( 'New type resource arcHIVE', 'text_domain' ),
|
'new_item_name' => __( 'New type resource', 'text_domain' ),
|
||||||
'add_new_item' => __( 'Add New type resource arcHIVE', 'text_domain' ),
|
'add_new_item' => __( 'Add New type resource', 'text_domain' ),
|
||||||
'edit_item' => __( 'Edit type resource arcHIVE', 'text_domain' ),
|
'edit_item' => __( 'Edit type resource', 'text_domain' ),
|
||||||
'update_item' => __( 'Update type of resource', 'text_domain' ),
|
'update_item' => __( 'Update type of resource', 'text_domain' ),
|
||||||
'separate_items_with_commas' => __( 'Separate type resource arcHIVE with commas', 'text_domain' ),
|
'separate_items_with_commas' => __( 'Separate type resource with commas', 'text_domain' ),
|
||||||
'search_items' => __( 'Search type of resource', 'text_domain' ),
|
'search_items' => __( 'Search type of resource', 'text_domain' ),
|
||||||
'add_or_remove_items' => __( 'Add or remove type of resource arcHIVE', 'text_domain' ),
|
'add_or_remove_items' => __( 'Add or remove type of resource', 'text_domain' ),
|
||||||
'choose_from_most_used' => __( 'Choose from the most used type of resource arcHIVE', 'text_domain' ),
|
'choose_from_most_used' => __( 'Choose from the most used type of resource', 'text_domain' ),
|
||||||
'not_found' => __( 'Type of resource arcHIVE Not Found', 'text_domain' ),
|
'not_found' => __( 'Type of resource Not Found', 'text_domain' ),
|
||||||
);
|
);
|
||||||
$rewrite = array(
|
$rewrite = array(
|
||||||
'slug' => 'resources',
|
'slug' => 'resources',
|
||||||
|
@ -118,21 +119,22 @@ function archive_wpplugin_custom_taxonomy_resource() {
|
||||||
'show_tagcloud' => true,
|
'show_tagcloud' => true,
|
||||||
'rewrite' => $rewrite,
|
'rewrite' => $rewrite,
|
||||||
);
|
);
|
||||||
register_taxonomy( 'archive_wpplugin_resource_type', array( 'archive_wpplugin_resource' ), $args );
|
// register_taxonomy( 'archive_wpplugin_taxonomy_type_resource', array( 'archive_resource' ), $args );
|
||||||
|
register_taxonomy( 'archive_resourcetype', array( 'archive_resource' ) , $args );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook into the 'init' action
|
// Hook into the 'init' action
|
||||||
add_action( 'init', 'archive_wpplugin_custom_taxonomy_resource', 0 );
|
add_action( 'init', 'archive_wpplugin_register_taxonomy_resource', 0 );
|
||||||
|
|
||||||
// changing the permalink
|
// changing the permalink
|
||||||
// http://wordpress.stackexchange.com/questions/108642/permalinks-custom-post-type-custom-taxonomy-post
|
// http://wordpress.stackexchange.com/questions/108642/permalinks-custom-post-type-custom-taxonomy-post
|
||||||
|
|
||||||
function archive_wpplugin_show_permalinks( $post_link, $id = 0 ){
|
function archive_wpplugin_show_permalinks( $post_link, $id = 0 ){
|
||||||
$post = get_post($id);
|
$post = get_post($id);
|
||||||
if ( is_object( $post ) && $post->post_type == 'archive_wpplugin_resource' ){
|
if ( is_object( $post ) && $post->post_type == 'archive_resource' ){
|
||||||
$terms = wp_get_object_terms( $post->ID, 'archive_wpplugin_resource_type' );
|
$terms = wp_get_object_terms( $post->ID, 'archive_resourcetype' );
|
||||||
if( $terms ){
|
if( $terms ){
|
||||||
return str_replace( '%archive_wpplugin_resource_type%' , $terms[0]->slug , $post_link );
|
return str_replace( '%archive_resourcetype%' , $terms[0]->slug , $post_link );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $post_link;
|
return $post_link;
|
||||||
|
|
Loading…
Reference in New Issue