added custom post Resources
This commit is contained in:
parent
401828178b
commit
aaf8d93f5b
|
@ -12,8 +12,8 @@
|
|||
* @package arcHIVE_WPPlugin
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* arcHIVE WP Plugin: arcHIVE WP Plugin for theme support
|
||||
* Plugin URI: https://arc-hive.zone/archive-wpplugin-uri/
|
||||
* Plugin Name: arcHIVE WP Plugin for theme support
|
||||
* Plugin URI: https://git.hangar.org/arcHIVE-tech/arc-hive-wordpress-plugin
|
||||
* Description: All the <strong>options</strong> for <strong>arcHIVE website</strong> which do not come by default with Wordpress.
|
||||
* Version: 1.1.0
|
||||
* Date: 2022 03 14
|
||||
|
@ -64,4 +64,4 @@ if ( is_admin() ) {
|
|||
include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-public-stylesheet.php');
|
||||
}
|
||||
|
||||
//include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-custom-post-type-resources.php');
|
||||
include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-custom-post-type-resources.php');
|
||||
|
|
|
@ -1,12 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* Custom post type Resources.
|
||||
*
|
||||
* @link https://arc-hive.zone
|
||||
* @since 1.1.0
|
||||
*
|
||||
* @package archive_wpplugin
|
||||
* @subpackage archive_wpplugin/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom post type Resources.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's activation.
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @package archive_wpplugin
|
||||
* @subpackage archive_wpplugin/includes
|
||||
* @author Jorge - vitrubio.net <jorge@vitrubio.net>
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Start custom post types
|
||||
* ----------------------------------------------------------------------------
|
||||
* https://developer.wordpress.org/plugins/post-types/registering-custom-post-types/
|
||||
* https://developer.wordpress.org/reference/functions/register_post_type/
|
||||
*/
|
||||
|
||||
// Register Custom Post Type
|
||||
function custom_post_type_resource_arcHIVE() {
|
||||
function archive_wpplugin_custom_post_resource() {
|
||||
|
||||
$labels = array(
|
||||
'name' => _x( 'All resources', 'Post Type General Name', 'text_domain' ),
|
||||
|
@ -24,23 +47,23 @@ function custom_post_type_resource_arcHIVE() {
|
|||
'not_found_in_trash' => __( 'We couldn\'t find any resource in the bin', 'text_domain' ),
|
||||
);
|
||||
$rewrite = array(
|
||||
'slug' => 'resources/%type_resource_arcHIVE%',
|
||||
'slug' => 'resources/%archive_wpplugin_resource_type%',
|
||||
'with_front' => true,
|
||||
'hierarchical' => true,
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'resource_arcHIVE', 'text_domain' ),
|
||||
'label' => __( 'archive_wpplugin_resource', 'text_domain' ),
|
||||
'description' => __( 'Resources arcHIVE', 'text_domain' ),
|
||||
'labels' => $labels,
|
||||
'supports' => array( 'title', 'editor', 'thumbnail', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes' ),
|
||||
'taxonomies' => array('post_tag','type_resource_arcHIVE'),
|
||||
'taxonomies' => array('category','post_tag','archive_wpplugin_resource_type'),
|
||||
'hierarchical' => true,
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => true,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_admin_bar' => true,
|
||||
'menu_position' => 15,
|
||||
'menu_position' => 5,
|
||||
'menu_icon' => 'dashicons-book',
|
||||
'can_export' => true,
|
||||
'has_archive' => 'resources',
|
||||
|
@ -49,20 +72,21 @@ function custom_post_type_resource_arcHIVE() {
|
|||
'capability_type' => 'post',
|
||||
'rewrite' => $rewrite,
|
||||
);
|
||||
register_post_type( 'resource_arcHIVE', $args );
|
||||
register_post_type( 'archive_wpplugin_resource', $args );
|
||||
|
||||
}
|
||||
|
||||
// Hook into the 'init' action
|
||||
add_action( 'init', 'custom_post_type_resource_arcHIVE', 0 );
|
||||
add_action( 'init', 'archive_wpplugin_custom_post_resource', 0 );
|
||||
|
||||
/**
|
||||
* Start custom taxonomies
|
||||
* ----------------------------------------------------------------------------
|
||||
* https://developer.wordpress.org/plugins/taxonomies/working-with-custom-taxonomies/
|
||||
*/
|
||||
|
||||
// Register Custom Taxonomy
|
||||
function custom_taxonomy_type_resource_arcHIVE() {
|
||||
function archive_wpplugin_custom_taxonomy_resource() {
|
||||
|
||||
$labels = array(
|
||||
'name' => _x( 'Type of resources arcHIVE', 'Taxonomy General Name', 'text_domain' ),
|
||||
|
@ -94,25 +118,23 @@ function custom_taxonomy_type_resource_arcHIVE() {
|
|||
'show_tagcloud' => true,
|
||||
'rewrite' => $rewrite,
|
||||
);
|
||||
register_taxonomy( 'type_resource_arcHIVE', array( 'resource_arcHIVE' ), $args );
|
||||
register_taxonomy( 'archive_wpplugin_resource_type', array( 'archive_wpplugin_resource' ), $args );
|
||||
}
|
||||
|
||||
// Hook into the 'init' action
|
||||
add_action( 'init', 'custom_taxonomy_type_resource_arcHIVE', 0 );
|
||||
add_action( 'init', 'archive_wpplugin_custom_taxonomy_resource', 0 );
|
||||
|
||||
// changing the permalink
|
||||
// http://wordpress.stackexchange.com/questions/108642/permalinks-custom-post-type-custom-taxonomy-post
|
||||
|
||||
function arcHIVE_show_permalinks( $post_link, $id = 0 ){
|
||||
function archive_wpplugin_show_permalinks( $post_link, $id = 0 ){
|
||||
$post = get_post($id);
|
||||
if ( is_object( $post ) && $post->post_type == 'resource_arcHIVE' ){
|
||||
$terms = wp_get_object_terms( $post->ID, 'type_resource_arcHIVE' );
|
||||
if ( is_object( $post ) && $post->post_type == 'archive_wpplugin_resource' ){
|
||||
$terms = wp_get_object_terms( $post->ID, 'archive_wpplugin_resource_type' );
|
||||
if( $terms ){
|
||||
return str_replace( '%type_resource_arcHIVE%' , $terms[0]->slug , $post_link );
|
||||
return str_replace( '%archive_wpplugin_resource_type%' , $terms[0]->slug , $post_link );
|
||||
}
|
||||
}
|
||||
return $post_link;
|
||||
}
|
||||
add_filter( 'post_type_link', 'arcHIVE_show_permalinks', 1, 2 );
|
||||
|
||||
?>
|
||||
add_filter( 'post_type_link', 'archive_wpplugin_show_permalinks', 1, 2 );
|
||||
|
|
Loading…
Reference in New Issue