Skip to content

Instantly share code, notes, and snippets.

@philliproth
Created February 16, 2021 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philliproth/bbb1226724858eaa07975f95506e87fe to your computer and use it in GitHub Desktop.
Save philliproth/bbb1226724858eaa07975f95506e87fe to your computer and use it in GitHub Desktop.
Plugin for Portfolio Custom Post Type
<?php
/*
Plugin Name: Site Plugin for philliproth.de
Description: Site specific code changes for example.com
*/
/* CPT */
/* custom post types */
function philliproth_cpt() {
$args = array(
'labels' => array(
'menu_name' => $page->post_title,
'name' => __( 'Portfolio', 'philliproth' ),
'add_new' => __( 'New Item', 'philliproth' ),
'add_new_item' => __( 'New Item', 'philliproth' ),
'edit_item' => __( 'Edit Item', 'philliproth' ),
'all_items' => __( 'All Items', 'philliproth' )
),
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'menu_position' => 20,
'query_var' => true,
'capability_type' => 'page',
'has_archive' => true,
'exclude_from_search' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'tags', 'post-formats'),
'rewrite' => array( 'with_front' => false, 'slug' => $page->post_name ),
'taxonomies' => array( 'tags' . $page->ID )
);
register_post_type( 'portfolio' . $page->ID, $args );
register_taxonomy( 'tags-' . $page->ID, 'portfolio' . $page->ID );
}
add_action( 'init', 'philliproth_cpt' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment