Support » Themes and Templates » noob custom post type question

  • Resolved jonsaul



    this is my first post and I am new to wordpress, but very much enjoying working with it.

    I have a question regarding my custom posts type defined as so…

    // Add new post type for Portfolio
    add_action('init', 'portfolio_init');
    function portfolio_init()
    	$portfolio_labels = array(
    		'name' => _x('Portfolio', 'post type general name'),
    		'singular_name' => _x('Portfolio', 'post type singular name'),
    		'all_items' => __('All projects'),
    		'add_new' => _x('Add new project', 'projects'),
    		'add_new_item' => __('Add new project'),
    		'edit_item' => __('Edit project'),
    		'new_item' => __('New project'),
    		'view_item' => __('View project'),
    		'search_items' => __('Search in portfolio'),
    		'not_found' =>  __('No projects found'),
    		'not_found_in_trash' => __('No projects found in trash'),
    		'parent_item_colon' => ''
    	$args = array(
    		'labels' => $portfolio_labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'query_var' => true,
    		'rewrite' => true,
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => 5,
    		'supports' => array('title','editor','thumbnail','excerpt'),
    		'has_archive' => 'projects'

    I am using the awesome Advanced custom fields plugin for my write panels, and all is workign fine, apart from when I go to I would like to see the archive, but at the moment i can only see it on, ??

    When I view a post from my custom posts type it will create a url such as

    I have a feeling I can change this in

    'has_archive' => 'projects'

    portion of my code but when I do nothing happens, I have a feeling i need to make some kind of flush function ?? but I cant work out if this is the case, or how to do that so far…

    Basically, my custom post type is called ‘Portfolio’, I want to have a link on my site that takes me to where I can see all posts for that type, and for the single view (which works fine)
    but why cant I have an archive at instead of which does actually produced a list of posts from my post type ??? HELP!!

Viewing 1 replies (of 1 total)
  • ok, sorry i’ve solved this.

    I realised updating and re-saving the permalinks settings has the desired effect of updating the functions file with my new archive location.

Viewing 1 replies (of 1 total)
  • The topic ‘noob custom post type question’ is closed to new replies.