Title: custom post type
Last modified: March 31, 2020

---

# custom post type

 *  [exolon](https://wordpress.org/support/users/exolon/)
 * (@exolon)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/custom-post-type-238/)
 * hi guy, i have create the custom post type, all work, but not show permalinks
   title,
    [img](https://i.imgur.com/Kfc6X07.jpg) this is the code:
 *     ```
       if ( ! function_exists('eventifb') ) {
   
           // Register Custom Post Type
           function eventifb() {
   
               $labels = array(
                   'name'                  => 'Eventi',
                   'singular_name'         => 'Evento',
                   'menu_name'             => 'Eventi',
                   'name_admin_bar'        => 'Eventi fb',
                   'archives'              => 'Archivio Eventi',
                   'attributes'            => 'Attributo Eventi',
                   'parent_item_colon'     => 'Parent Event:',
                   'all_items'             => 'Tutti gli eventi',
                   'add_new_item'          => 'add nuovo evento',
                   'add_new'               => 'Aggiungi Evento',
                   'new_item'              => 'Nuovo Evento',
                   'edit_item'             => 'Modifica Evento',
                   'update_item'           => 'Aggiorna Evento',
                   'view_item'             => 'Vedi Evento',
                   'view_items'            => 'Vedi Eventi',
                   'search_items'          => 'Cerca Evento',
                   'not_found'             => 'Not Found',
                   'not_found_in_trash'    => 'Non trovo nel cestino',
                   'featured_image'        => 'Featured Image',
                   'set_featured_image'    => 'Set featured image',
                   'remove_featured_image' => 'Remove featured image',
                   'use_featured_image'    => 'Use as featured image',
                   'insert_into_item'      => 'Inserisci nell evento',
                   'uploaded_to_this_item' => 'Carica da questo evento',
                   'items_list'            => 'Items list',
                   'items_list_navigation' => 'Items list navigation',
                   'filter_items_list'     => 'Filter items list',
               );
               $args = array(
                   'label'                 => 'Evento',
                   'description'           => 'Eventi Presi da Facebook',
                   'labels'                => $labels,
                   'supports'              => array( 'title', 'editor', 'thumbnail', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats' ),
                   'taxonomies'            => array( 'category', 'post_tag' ),
                   'hierarchical'          => false,
                   'public'                => true,
                   'show_ui'               => true,
                   'show_in_menu'          => true,
                   'menu_position'         => 5,
                   'menu_icon'             => 'dashicons-media-document',
                   'show_in_admin_bar'     => true,
                   'show_in_nav_menus'     => true,
                   'can_export'            => true,
                   'has_archive'           => 'eventslug',
                   'exclude_from_search'   => false,
                   'publicly_queryable'    => true,
                   'capability_type'       => 'post',
               );
               register_post_type( 'eventi', $args );
   
           }
           add_action( 'init', 'eventifb', 0 );
   
           }
       ```
   

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/custom-post-type-238/#post-12608140)
 * Did you visit the permalinks setting screen after you added your code? This is
   necessary if you don’t have code flushing rewrite rules.
 * Is that a breadcrumb trail that should be showing? What’s the code that is supposed
   to show a permalink? It may not be setup for custom post types. Generally speaking
   you can get the permalink for any post of any type with `get_the_permalink()`
   if within the loop. Outside the loop you need to pass a post object or ID. On
   single post pages this can be done with `get_queried_object_id()`
 *  Thread Starter [exolon](https://wordpress.org/support/users/exolon/)
 * (@exolon)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/custom-post-type-238/#post-12608757)
 * yes, in the theme avas not is configuration permalinks
    actually when i configured
   this new custom post type, i noticed that the default file is used for the posts,
   while the avas theme uses another type of file for the post
 *  Thread Starter [exolon](https://wordpress.org/support/users/exolon/)
 * (@exolon)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/custom-post-type-238/#post-12609070)
 * the page that should call the permalinks is header.php and contains this code
 *     ```
                                       <!-- Search icon -->
                                       <?php do_action('tx_search_icon'); ?>
                                       <!-- Menu Button -->
                                       <?php do_action('tx_menu_btn'); ?>
                                       </div><!-- /.menu-area-righ -->
                                   </div>
                               </div> <!-- /.row -->
                           </div><!-- /.container -->
                       </div><!-- /#h-style-3 -->
                       <?php } ?>    
   
                       <?php
                       if( !is_front_page() && !is_404() && !is_page_template( 'templates/no-sub.php' )) :
                           if (class_exists('ReduxFramework')) {
                               if($tx['sub-header-switch']) {
                                   get_template_part( 'template-parts/header/sub', 'header' );
                               }
                           } else {
                               get_template_part( 'template-parts/header/sub', 'header' );
                           }
                       endif;
                       ?><!-- sub header -->
   
                   </header><!-- /#header -->   
   
               <!-- /.row -->
       ```
   
    -  This reply was modified 6 years, 4 months ago by [bcworkz](https://wordpress.org/support/users/bcworkz/).
      Reason: excess code removed
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/custom-post-type-238/#post-12612977)
 * There is no breadcrumb trail or permalink code in the header file. Maybe it’s
   in ‘template-parts/header/sub’. It’s also possible the template file code is 
   correct and it’s not working as expected due to some permalink filter hook. Filter
   hooks are usually in functions.php or some other PHP file referenced from functions.
   php.
 * If you find the need to post large amounts of code, please use pastebin.com or
   a gist.github.com. I’ve removed a sizable chunk of the header file you posted
   since it’s not applicable to the issue at hand.
 * You can manage which template files are used for your post type by giving them
   certain names. See [https://developer.wordpress.org/themes/basics/template-hierarchy/](https://developer.wordpress.org/themes/basics/template-hierarchy/)
   
   You could copy the desired theme file into a new file appropriately named.
 *  Thread Starter [exolon](https://wordpress.org/support/users/exolon/)
 * (@exolon)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/custom-post-type-238/#post-12613109)
 * i have add customposttype in the function.php /avas-child/function.php
 *  Thread Starter [exolon](https://wordpress.org/support/users/exolon/)
 * (@exolon)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/custom-post-type-238/#post-12617568)
 * isn’t there a way to tell the customposttype to use a file for events?
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/custom-post-type-238/#post-12618272)
 * Yes, the previously provided link tells us to copy the desired template file (
   can rename if it is not used for anything else) to a new name based on post type.
   For single posts use `"single-{$post_type}.php"`. For archive lists use `"archive-{
   $post_type}.php"`.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘custom post type’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 7 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/custom-post-type-238/#post-12618272)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
