Custom Post Geben Sie den Duplikations-Slug für neue Posts ein

// register custom post type forums function fp_forum_post_type() { // set up labels $labels = array( 'name' => 'Forums', 'singular_name' => 'Forum', 'add_new' => 'Add New Forum', 'add_new_item' => 'Add New Forum', 'edit_item' => 'Edit Forum', 'new_item' => 'New Forum', 'all_items' => 'All Forums', 'view_item' => 'View Forum', 'search_items' => 'Search Forums', 'not_found' => 'No Forums Found', 'not_found_in_trash' => 'No Forums found in Trash', 'parent_item_colon' => 'Category:', 'menu_name' => 'Forums', ); //register post type register_post_type( 'forums', array( 'labels' => $labels, 'has_archive' => true, 'public' => true, 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail','page-attributes' ), 'exclude_from_search' => false, 'capability_type' => 'post', 'query_var' => true, 'rewrite' => array( 'slug' => 'forums' ), ) ); } 

Aus irgendeinem Grund, wenn ich einen neuen Post erstelle, dupliziert er den gleichen Slug wie der erste Post, also sag die Slug ist Foren = Hallo-Welt, der nächste Post wird automatisch Foren = Hallo-Welt-2, egal was der Titel ist. ..

Ich habe mehrmals auf Neuinstallation getestet und bekomme das gleiche Problem …

UPDATE: Ich habe festgestellt, dass das Problem von meinem benutzerdefinierten Metabox verursacht wird:

 function add_forum_attributes_metabox(){ add_meta_box( 'forum_attributes', __('Forum Attributes', 'forumpress'), 'forum_attributes', 'forums', 'side', 'high', array( 'id' => 'forum_attributes') ); 

}

 function save_forum_attributes_metabox($post_id, $post){ // Don't wanna save this now, right? if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; if ( !isset( $_POST['forum_attributes_nonce'] ) ) return; if ( !wp_verify_nonce( $_POST['forum_attributes_nonce'], 'forumpress/includes/metaboxes/metaboxes.php' ) ) return; // We do want to save? Ok! $key = 'forum_type'; $value = $_POST["forum_type"]; if ( get_post_meta( $post->ID, $key, FALSE ) ) { // If the custom field already has a value update_post_meta( $post->ID, $key, $value ); } else { // If the custom field doesn't have a value add_post_meta( $post->ID, $key, $value ); } if ( !$value ) delete_post_meta( $post->ID, $key ); // Delete if blank $key = 'forum_category'; $value = $_POST["forum_category"]; if ( get_post_meta( $post->ID, $key, FALSE ) ) { // If the custom field already has a value update_post_meta( $post->ID, $key, $value ); } else { // If the custom field doesn't have a value add_post_meta( $post->ID, $key, $value ); } if ( !$value ) delete_post_meta( $post->ID, $key ); // Delete if blank $key = 'forum_status'; $value = $_POST["forum_status"]; if ( get_post_meta( $post->ID, $key, FALSE ) ) { // If the custom field already has a value update_post_meta( $post->ID, $key, $value ); } else { // If the custom field doesn't have a value add_post_meta( $post->ID, $key, $value ); } if ( !$value ) delete_post_meta( $post->ID, $key ); // Delete if blank $key = 'forum_order'; $value = $_POST["forum_order"]; if ( get_post_meta( $post->ID, $key, FALSE ) ) { // If the custom field already has a value update_post_meta( $post->ID, $key, $value ); } else { // If the custom field doesn't have a value add_post_meta( $post->ID, $key, $value ); } if ( !$value ) add_post_meta( $post->ID, $key, '0' ); // add 0 if blank 

}

Solutions Collecting From Web of "Custom Post Geben Sie den Duplikations-Slug für neue Posts ein"

Getriggers:

Dummer Fehler, den ich machte, war wp_query in der benutzerdefinierten Metabox-Ausgabe zu verwenden …

Gesicht Palme

Wenn Sie in diesem Beitrag dasselbe Problem gegooglt haben, müssen Sie eine andere Abfragemethode verwenden, da sie mit der Seite in Konflikt steht.

Verwenden Sie dies:

 $query = get_posts( array( 'post_type' => 'forums', 'post_status' => 'publish' ) ); 

behebt dieses Problem.