Need to use a wordpress page twice in different menu items

I am currently developing a custom WordPress theme and ran into a problem.

I have created a custom template that displays it’s subpages as a category-overview. It’s for products, and the structure is as follows:

Read More
Home (page id #3)
Products (page id #4)
    Category 1 (page id#6, child of page #4)
    Category 2 (page id#7, child of page #4) 
    Category 3 (page id#8, child of page #4)
    …

Page #4 (the products page) displays an overview of the categories. Now, the front page should also display an overview of the categories, just styled differently (also using different markup, so CSS-only won’t do the job).

I already modified the template to react to being called on the front page. The detection is working and if I define the products page as the home page, it looks like intended.

But there is one problem: Now in the navigation (which is a custom menu), the “Products” item links to the home page, and such is not working as the category overview. It seems wordpress overwrites the role of the page to be the home page even though I need it to be an instance of it’s own, with the corresponding url of http://www.client.com/products.

So, if the products page is also used as the front page my navigation structure is being messed up and I cannot get to http://www.client.com/products/ anymore.

Using another page with the same template for the front page will not work, because it will not have the subpages I’m querying.

What I want:

Home (page id #4) >> http://www.client.com/, overview style #1
Products (page id #4) >> http://www.client.com/products/, overview style #2
    Category 1 (page id#6, child of page #4)
    Category 2 (page id#7, child of page #4) 
    Category 3 (page id#8, child of page #4)
    …

What I have:

Home (page id #4) >> http://www.client.com/, category overview style #1
Products (page id #4) >> http://www.client.com/, category overview style #1
    Category 1 (page id#6, child of page #4)
    Category 2 (page id#7, child of page #4) 
    Category 3 (page id#8, child of page #4)
    …

Any ideas?

Related posts

Leave a Reply

1 comment

  1. It seems that the problem can’t be solved this way, but I found a workaround.

    • Products (page id #4) is defined as “posts page” and kept in the navigation.
    • Home is a page on it’s own (page id #9)

    Both pages, Products & Home, use a custom template ‘Products’, which queries against the posts page:

    $pages = get_pages( array('child_of' => get_option('page_for_posts')) );
    

    It’s not beautiful, but it works.