Skip to content

Commit 8c90bf2

Browse files
committed
Added ability to rewrite post type URLs
1 parent 7fe2a10 commit 8c90bf2

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

src/Raskoh/PostType.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
class PostType
1111
{
12-
13-
1412
/**
1513
* @var
1614
*/
@@ -99,6 +97,13 @@ class PostType
9997
* @var Taxonomy
10098
*/
10199
private $taxonomies = array();
100+
101+
/**
102+
* @var array
103+
*/
104+
private $rewrite = array();
105+
106+
102107
private $priority;
103108

104109

@@ -151,6 +156,11 @@ public function hookInWordPress()
151156
$args[ 'menu_icon' ] = $this->icon;
152157
}
153158

159+
if (isset( $this->rewrite[ 'slug' ] )) {
160+
$args[ 'rewrite' ] = $this->rewrite;
161+
}
162+
163+
154164
register_post_type($this->slug, $args);
155165
flush_rewrite_rules();
156166
}
@@ -609,5 +619,17 @@ public function setPriority( $priority )
609619
return $this;
610620
}
611621

622+
623+
/**
624+
* Rewrite post type URL
625+
*
626+
* @param $slug
627+
* @return $this
628+
*/
629+
public function rewrite( $slug )
630+
{
631+
$this->rewrite[ 'slug' ] = $slug;
632+
return $this;
633+
}
634+
612635
}
613-

0 commit comments

Comments
 (0)