Forums

Using a static page as it's own page and as the home page (2 posts)

  1. chknoflach
    Member
    Posted 4 months ago #

    Hi all,

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

    I have a template that displays subpages in a category-overview for the client's products, so the structure is this:

    Home
    Products
        Category 1
        Category 2
        Category 3
        …

    And as such is reflected in the navigation.

    Now the front page needs to also display an overview of the categories, just styled differently. So I modified the template and defined the page as the home page - everything working fine so far.

    The only problem with this solution: Now in the navigation, 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.

    What I want:
    http://www.client.com/ >> product overview style #1, using subpages
    http://www.client.com/products/ >> product overview style #2, using subpages

    And a navigation that correctly displays http://www.client.com/products/ as the url for the navigation item "Products".

    What I have:
    http://www.client.com/ >> product overview style #1, using subpages
    http://www.client.com/products/ >> redirecting tho http://www.client.com/

    And a navigation that incorrectly displays http://www.client.com/ as the url for the navigation item "Products".

    Any ideas?

  2. chknoflach
    Member
    Posted 3 months ago #

    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.

Reply

You must log in to post.

About this Topic