• I made a wordpress theme with the custom post type “event”. When I create 2 events with the same title the slug is generated correct: e.g. “/event/my-first-event” and “/event/my-first-event-2”. But if I browse to “/event/my-first-event” – the loop gives me both events. If I browse to “/event/my-first-event-2” I get the 404 page.

    Any idea how to fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • What is your code for this?

    Thread Starter juliussohn

    (@juliussohn)

    function event_post_type() {
    	$labels = array(
    		'name' => __('Veranstaltungen', 'filmnaechte_theme'),
    		'singular_name' => __('Veranstaltung', 'filmnaechte_theme'),
    
    	);
    
    	$args = array(
    
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'show_in_menu' => true,
    		'query_var' => true,
    		'rewrite' => array('slug' => _x('veranstaltung', 'URL Slug', 'filmnaechte_theme')),
    		'capability_type' => 'post',
    		'has_archive' => _x('veranstaltungen', 'URL Slug', 'filmnaechte_theme'),
    		'hierarchical' => false,
    		'menu_position' => null,
    		'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt'),
    		'menu_icon' => 'dashicons-calendar',
    	);
    
    	register_post_type('event', $args);
    	flush_rewrite_rules();
    }
    add_action('init', 'event_post_type');
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘custom post type with duplicate title doesn't get queryed by slug’ is closed to new replies.