-
AuthorPosts
-
January 31, 2017 at 12:07 pm #740578
Good morning,
I wonder if you can help. I’m sure I’m being utterly dense, but I can’t get my custom post type to display via a template file. So far I’ve done the following:
Created a custom post type called ‘Agent’ which is functioning well. My code is here:
// Register Agent Post Type function agent() { $labels = array( 'name' => _x( 'Agents', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Agent', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Agents', 'text_domain' ), 'name_admin_bar' => __( 'Agents', 'text_domain' ), 'archives' => __( 'Agent Archives', 'text_domain' ), 'attributes' => __( 'Agent Attributes', 'text_domain' ), 'parent_item_colon' => __( 'Parent Item:', 'text_domain' ), 'all_items' => __( 'All Agents', 'text_domain' ), 'add_new_item' => __( 'Add New Agent', 'text_domain' ), 'add_new' => __( 'Add Agent', 'text_domain' ), 'new_item' => __( 'New Agent', 'text_domain' ), 'edit_item' => __( 'Edit Agent', 'text_domain' ), 'update_item' => __( 'Update Agent', 'text_domain' ), 'view_item' => __( 'View Agent', 'text_domain' ), 'view_items' => __( 'View Agents', 'text_domain' ), 'search_items' => __( 'Search Agents', 'text_domain' ), 'not_found' => __( 'Not found', 'text_domain' ), 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ), 'featured_image' => __( 'Featured Image', 'text_domain' ), 'set_featured_image' => __( 'Set featured image', 'text_domain' ), 'remove_featured_image' => __( 'Remove featured image', 'text_domain' ), 'use_featured_image' => __( 'Use as featured image', 'text_domain' ), 'insert_into_item' => __( 'Insert into item', 'text_domain' ), 'uploaded_to_this_item' => __( 'Uploaded to this item', 'text_domain' ), 'items_list' => __( 'Agents list', 'text_domain' ), 'items_list_navigation' => __( 'Agents list navigation', 'text_domain' ), 'filter_items_list' => __( 'Filter items list', 'text_domain' ), ); $args = array( 'label' => __( 'Agent', 'text_domain' ), 'description' => __( 'Agent Post Type', 'text_domain' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail', 'post-formats', ), 'taxonomies' => false, 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'show_in_admin_bar' => false, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'post', ); register_post_type( 'agent', $args ); } add_action( 'init', 'agent', 0 ); add_action( 'init', 'build_agent_taxonomies', 0 ); function build_agent_taxonomies() { register_taxonomy( 'agent_location', 'agent', // The custom post type array( 'hierarchical' => true, 'label' => 'Agent Location', 'query_var' => true, 'rewrite' => true, 'show_ui' => true, 'show_admin_column' => true ) ); }
I’ve tried to created a custom template by copying single.php from the Enfold parent theme (I’m using a child theme) and renaming it single-agent.php. I’ve reset permalinks and tired a few times but none of my changes appear to be having any effect.
Any help / slaps around the face would be appreciated!
Regards,
Ash
February 2, 2017 at 11:38 pm #742088Hey ashloudon,
The code you posted is working properly since I can see the Agents post type in the backend. Also when I checked in Appearance > Editor, I can find the single-agent.php. Can we request for the ftp access? so we can atleast test it.
Best regards,
NikkoFebruary 3, 2017 at 12:38 pm #742346Hi Nikko,
Sure thing. FTP deets are in the private box below :)
February 4, 2017 at 12:56 am #742619Hi,
I checked it and it works fine, I have tested it (link in Private Content), the reason why any changes you do with the single-agent.php isn’t reflecting is because the avia layout builder is enabled which doesn’t use single.php or single-agent.php instead it uses template-builder.php
I have replaced text_domain in your code to avia_framework. I hope the information I gave helps.Best regards,
Nikko -
AuthorPosts
- You must be logged in to reply to this topic.