• Hi all,

    I have been working on modifying the permalinks of my website. So far I have managed to create the pages I want to use custom permalinks for. Basically members page is a parent of teachers and students. Easy stuff so far

    So this is the URL’s I have to work on for now.

    www…./members
    www…/members/teachers
    www…/members/students

    Now let’s say I want each post to be separate within those pages. So I created two categories “teachers-posts” and “students-posts”.
    Then I created two posts. one called “teacher-post-1” and “student-post-1” each which belonging to the appropriate category

    My first question:

    • How to set two different post pages in Dashboard>Settings>Readings>Your homepage displays

    When I access www…/members/teachers there is a post in that page but when I click on the post the url changes www…/teachers-posts/teacher-post-1

    So that leads to another question:

    • How to change each post permalink to be as www…/members/teachers/teachers-posts/teacher-post-1????

    Thanks for your time, any help would be much appriciated!

    • This topic was modified 3 years, 5 months ago by sslv.
    • This topic was modified 3 years, 5 months ago by sslv.
    • This topic was modified 3 years, 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You cannot have two different posts pages. A posts page serves one purpose, to list published posts (not pages). You can however have several different page templates, each of which can list the results of any query you might want to make. But if your posts are well categorized, a category archive page could achieve the same end, but the URL will be more like /category/teachers-posts/. It’s outside of the usual page hierarchy.

    The complete page hierarchy is what replaces the %postname% tag in permalink settings. A category tag can occur before or after this, but it cannot interrupt the page hierarchy. You can do /category-name/parent-page/child-page/, but not /parent-page/category-name/child-page/.

    N.B. by default pages do not have categories, but some custom code can make it so.

    Also, pages and posts are actually both different types of posts, so you cannot combine their names in one URL. You cannot normally do /page-name/post-name/. One’s options are expanded if you were to define additional rewrite rules, but that can get really complicated if you are not sure what you are doing. Added rewrite rules can create unanticipated conflicts with the existing rewrite rules.

    Without knowing where you’re going with your desired permalinks, it’s hard to make meaningful suggestions. On the surface though your scheme seems overly complicated. Why not simply have a bunch pf posts which are assigned certain categories and have URLs like /teachers-posts/any-post-name/? Having members and teachers URL elements in addition seems redundant. (disclaimer: I hate redundant data ?? ) A listing of all teacher’s posts will be at /category/teachers-posts/.

    Thread Starter sslv

    (@sslv)

    Hi @bcworkz ! Thanks for your feedback. I do now understand how it works. I would follow your suggestions and keep the website simple, just like any other website. However I have one last question in relation with what you have suggested above.

    Would it be the same situation when dealing with user profiles??

    For example : www…/parent-page/child-page/user-id

    Or would it have to have the suggested criteria??

    For example : www…/category-name/user-id

    Moderator bcworkz

    (@bcworkz)

    Users are not even a type of post, so you cannot directly relate categories to users. And the only way users are related to pages is by who authored the page. Of course pages could be categorized, so there could be an indirect relation there. %author% is a predefined permalink tag, so /%postname%/%author%/ is a possible permastruct. However /%category%/%author%/ is illogical because categories are for posts or maybe pages.

    The default permalink to user profiles is /author/user-id/. As implied, it’s only valid for those who have written at least one post. Profiles are not normally available to users who have not authored a post. This not to say that you couldn’t create page names matching user IDs that contain user bios.

    If you have a need to categorize users directly, the simplest way is to create some custom roles like “teacher” or “student”. Assign appropriate capabilities to each role. Another way would be to assign a particular user meta value to each user. You’d need to use a plugin or custom code to assign meta values or create custom roles.

    If you start getting into custom code, a lot of things are possible that are not normally so. But unless there’s a good reason for it, developing the necessary code may not be worth the effort.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to use permalinks (parent-page/-child-page/category/post-name)’ is closed to new replies.