Set up Custom-Post-Type Author Archive


I’ve set up a custom-post-type on a site for jobs, and this all works fine. When I click on the author (my name) on the Custom Post Type though it goes to the archive.php file (as you can see in the 3rd image).

I’ve set it up so that when when you click on the category shown in the first photo, this goes to a custom taxonomy archive template file taxonomy-job_type.php. There doesn’t seem to be an author-cpt.php template file though in the template hierarchy?

How do I set it so when someone clicks the author of a custom-post-type it shows that author’s CPT posts only?

I’ve included the code from my function.php file and the images of what is happening. Any help would be awesome.

function job_post_types() {
    register_post_type('job', array(
            'rewrite' => array('slug' => 'jobs'),
            'menu_icon' => 'dashicons-id-alt',
            'has_archive' => true,
            'public' => true,
            'publicly_queryable' => true,
            'supports' => array('title', 'editor', 'author', 'excerpt', 'custom-fields'),
            'taxonomies' => array('job_type'), // we have used this from the taxonomies below. Default entry should be ('category', 'post_tag)

            'labels' => array(
            'name' => 'Jobs',
            'add_new_item' => 'Add New Job',
            'edit_item' => 'Edit Job',
            'all_items' => 'All Jobs',
            'singular_name' => 'Job'

add_action('init', 'job_post_types');

function job_type_taxonomy(){

    $labels = array(
        'name'              => 'Job Types',
        'singular_name'     => 'Job Type',
        'search_items'      => 'Search Job Types',
        'all_items'         => 'All Job Types',
        'parent_item'       => 'Parent Job Type',
        'parent_item_colon' => 'Parent Job Type:',
        'edit_item'         => 'Edit Job Type',
        'update_item'       => 'Update Job Type',
        'add_new_item'      => 'Add New Job Type',
        'new_item_name'     => 'New Job Type Name',
        'menu_name'         => 'Job Type',

    $args = array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'job_type' ),

    register_taxonomy( 'job_type', array( 'job' ), $args );

    add_action('init', 'job_type_taxonomy');

Any help would be great

CPT with my author name ‘Paul’ in the meta
enter image description here

After clicking my name I go to the main blog index archive page for my name
enter image description here

Show Current Template File plugin confirms archive.php is the template file being outputted.
enter image description here

, , Paul12_ 6 months 0 Answers 66 views 0

Leave an answer