1

I am working now on a new WordPress theme and I want to make a help center system to allow users that will buy my theme do add helper articles.

So my plan is:

1- Make a normal new page and create the page-help.php file.

2- Create two post types first named sections and the second article.

3- Add the sections posts and articles inside the page-help file.

The problem now that I don't need the link of sections and articles be directly like this:

http://localhost/section/using-wordpres/
http://localhost/article/how-to-use-the-wordpres/

I want to make a rewrite rule to add help beside the section and article post type to be the final link like that:

http://localhost/help/section/using-wordpres/
http://localhost/help/article/how-to-use-the-wordpres/

Really this is very important for me and I hope anyone helps me to make this or at least something like that I want.

Thanks in advance.

2
  • You can control those values with the slug argument when you register your post types, you don't need to add any additional rewrite rules.
    – Milo
    Aug 13, 2018 at 2:00
  • @Milo Really thank you for your reply please continue with me, Did you mean something like this? rewrite' => array('slug' => 'help')? this will change the name of post type to something else will not like I need.
    – John
    Aug 13, 2018 at 2:05

1 Answer 1

1

You can achieve this when you register your post types. The slug can be a path:

$section_args = array(
    'rewrite' => array( 'slug' => 'help/section' ),
    // your other args...
);

$article_args = array(
    'rewrite' => array( 'slug' => 'help/article' ),
    // your other args...
);
1
  • Thank you very much I never thought that I can make it like this :)
    – John
    Aug 13, 2018 at 4:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.