php - Renaming the slug of my custom post type in wordpress doesnt work anymore and keeps the old slug -
php - Renaming the slug of my custom post type in wordpress doesnt work anymore and keeps the old slug -
i have been working on wordpress theme few weeks , facing next problem: have custom post type called "guide" , used rewrite slug alter "stappenplan". alter "application" rewrite doesnt work. doesnt reach archive.php file weird. using next code register custom post type.
$guides = new \kc\contenttype('guide', ['rewrite' => ['slug' => 'application'],'menu_icon' => get_template_directory_uri().'/img/icons/application.svg','has_archive' => true], ['plural_name' => 'applications']);
and helper class looks follows:
<?php namespace kc; class contenttype { public $type; public $options = []; public $labels = []; /** * creates new contenttype object * @param string $type * @param array $options * @param array $labels */ public function __construct($type, $options = [], $labels = []) { $this->type = $type; $default_options = [ 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => ['slug' => strtolower($type)], 'capability_type' => 'page', 'has_archive' => true, 'hierarchical' => true, 'taxonomies' => ['post_tag','category'], 'supports' => ['title', 'editor', 'revisions', 'thumbnail','page-attributes','excerpt'] ]; $required_labels = [ 'singular_name' => ucwords($this->type), 'plural_name' => ucwords($this->type) ]; $this->options = $options + $default_options; $this->labels = $labels + $required_labels; $this->options['labels'] = $labels + $this->default_labels(); add_action('init', array($this, 'register')); } /** * registers content type using wp core function(s) * @return null */ public function register() { register_post_type($this->type, $this->options); } /** * creates intelligent default labels required singular , plural labels * @return array */ public function default_labels() { homecoming [ 'name' => $this->labels['plural_name'], 'singular_name' => $this->labels['singular_name'], 'add_new' => 'add new ' . $this->labels['singular_name'], 'add_new_item' => 'add new ' . $this->labels['singular_name'], 'edit' => 'edit', 'edit_item' => 'edit ' . $this->labels['singular_name'], 'new_item' => 'new ' . $this->labels['singular_name'], 'view' => 'view ' . $this->labels['singular_name'] . ' page', 'view_item' => 'view ' . $this->labels['singular_name'], 'search_items' => 'search ' . $this->labels['plural_name'], 'not_found' => 'no matching ' . strtolower($this->labels['plural_name']) . ' found', 'not_found_in_trash' => 'no ' . strtolower($this->labels['plural_name']) . ' found in trash', 'parent_item_colon' => 'parent ' . $this->labels['singular_name'] ]; } }
hopefuly bad , not wordpress issue.
i solved problem myself going settings->permalinks in wordpress cms , changing setting different one. save after doing , refres page.
changing after solved problem!
php wordpress
Comments
Post a Comment