• Made a custom post type in functions.php

    add_action('init', 'fossil_post_type_register');
    
    function fossil_post_type_register() {
    
    	$labels = array(
    		'name' => _x('Fossils', 'post type general name'),
    		'singular_name' => _x('Fossil', 'post type singular name'),
    		'add_new' => _x('Add New', 'portfolio item'),
    		'add_new_item' => __('Add New Fossil'),
    		'edit_item' => __('Edit Fossil'),
    		'new_item' => __('New Fossil'),
    		'view_item' => __('View Fossil'),
    		'search_items' => __('Search Fossils'),
    		'not_found' =>  __('Nothing found'),
    		'not_found_in_trash' => __('Nothing found in Trash'),
    		'parent_item_colon' => ''
    	);
    
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
            'show_in_menu' => true,
    		'query_var' => true,
    		'menu_icon' => 'dashicons-plus-alt',
    		'rewrite' => array('slug' => 'fossil', 'with_front' => FALSE),
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => null,
    		'has_archive' => true,
    		'supports' => array('thumbnail', 'comments')
    	); 
    
    	register_post_type( 'fossil' , $args );
    }

    All I want is for the url mysite.com/fossil/%post_id/ to load the use the page single-fossil.php to display the information on that custom post and for the url mysite.com/fossil/ to use the page archive-fossil.php to show all of posts of this custom type.

    Currently my permalink is using custom structure /%post_id%/. No matter how I fiddle with the rewrite slug or change permalink structure I can’t get the urls to display the content I want. I’m sure I could you wordpress rewrite and define my own custom rewrites but I feel like that is overkill for what I’m trying to accomplish? Anyone have a clue where I am botching this?

Viewing 1 replies (of 1 total)
  • Thread Starter atmojones

    (@atmojones)

    I should also clarify that with my current setting the archive page works but the links it generates are to mysite.com/fossil/%title%/ for single posts. This does not work for me because title is not supported by my custom post type. so I need the links to use the post_id

Viewing 1 replies (of 1 total)
  • The topic ‘custom post url rewrites’ is closed to new replies.