WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can't understand custom post ype rewrite rule! (4 posts)

  1. au.petrone
    Member
    Posted 1 year ago #

    Hi everyone! I'm trying to transorm this

    http://localhost/wp_pluginDev/?post_type=corso

    in

    http://localhost/wp_pluginDev/corsi/.

    This is the code I used to register my custom post type:

    function corso_register() {
    
    	$labels = array(
    		'name' => 'Corsi',
    		'singular_name' => 'Corso',
    		'add_new' => 'Aggiungi un corso',
    		'add_new_item' => 'Aggiungi un corso',
    		'edit_item' => 'Modiica il corso',
    		'new_item' => 'Nuovo corso',
    		'view_item' => 'Visualizza corso',
    		'search_items' => 'Cerca corso',
    		'not_found' =>  'Non ho trovato nulla',
    		'not_found_in_trash' => 'Non ho trovato nulla nel cestino',
    		'parent_item_colon' => ''
    	);
    
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'query_var' => true,
    		'rewrite' => array(
    
    			'slug' => 'corso',
    
    		 ),
    		'has_archive' => 'corsi',
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => null,
    		'supports' => array('title','editor','thumbnail')
    	  ); 
    
    	register_post_type( 'corso' , $args );
    
    	global $wp_rewrite;
     	$wp_rewrite->flush_rules();
    }

    The 'has_archive' is set to 'corsi' so why it doesn't work??Thank you for the help!

    PS: I searched or old discussion but i couldn't find nothing!

  2. Tara
    Member
    Posted 1 year ago #

    this codex has lots of info and useful links: http://codex.wordpress.org/Post_Types

  3. Set your slug to "corsi" and then go to Settings > Permalinks and Save Changes.

  4. au.petrone
    Member
    Posted 1 year ago #

    Thank you! Solved going in Settings!

Topic Closed

This topic has been closed to new replies.

About this Topic