• Resolved davida77

    (@davida77)


    I want to achieve that I can have this url structure for the page ‘/category/{specific-category)’. So I created category as parent page and then the specific category page as nested page.

    I created a custom template file. I can select it in page attributes on the page. However whenever I select the custom template on a page which has a parent page selected it keeps defaulting to index.php even though it stays selected. Whenever I deselect the parent page for it, it does use the custom template.

    Why does this happen and how can I achieve what I want?

Viewing 3 replies - 1 through 3 (of 3 total)
  • hafeez5

    (@hafeez5)

    This issue occurs because when you set a parent page, WordPress may override the custom template selection. To achieve your desired URL structure (/category/{specific-category}), you should consider using custom post types or taxonomies instead of parent-child pages, as this may better suit your needs and avoid template conflicts.

    • This reply was modified 1 year ago by bcworkz. Reason: remove spammy link
    Moderator bcworkz

    (@bcworkz)

    I think WP is getting confused about what sort of request is being made, so it assigns the wrong template.

    It is possible to associate the category taxonomy to pages as well as posts. Then you could assign a category term to a page so a category term request could lead to the related page.

    You could instead use the “template_include” filter to force WP to use a particular template for a specific kind of request.

    Thread Starter davida77

    (@davida77)

    Thanks for the answers, indeed the problem was that “category” is used for the category templates so it could not determine if it needed to use the category template. I changed it to ”categories” and now its child pages do react on the correct child template.

    • This reply was modified 1 year ago by davida77.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress nested (child) page with custom template’ is closed to new replies.