WordPress.org

Support

Support » How-To and Troubleshooting » url path with children pages of a frontpage static page

url path with children pages of a frontpage static page

  • I’ve set up the frontpage as a static page in Reading. The page has a title Homepage and slug “homepage”. Being the frontpage now, the slug is never shown.

    BUT, if I add children pages to Homepage, their path will be:

    example.org/homepage/child1
    example.org/homepage/child2
    example.org/homepage/child3

    That is ugly. Shouldn’t it be:

    example.org/child1
    example.org/child2
    example.org/child3

    ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • This is a default structure that WP will keep for parent/child pages.
    Is there any particular reason why you assign pages as children of “homepage” page?

    Reason: the design I was given expects that in the homepage there are 3 boxes in a row each one with a title and a thumbnail (featured image) and each one pointing to a page and I though to get those 3 pages with a call to wp_list_pages() and the parameter “child_of” set to current homepage post ID from the homepage template.

    Since that solution was ugly dued to the resulting generated url, I’ve moved those 3 pages in the root and set up a settings options page in the dashboard to specifiy the 3 IDs of the pages I want to make appear in the boxes as a comma separate list of ids (12,34,56).

    Hmm, how about adding custom field to each post you want to appear on home page and run query to get posts with key/value pair?
    So lets say you add custom field slider=home to each page you want added.
    Then query like this:

    $featuredArgs = array(
        'post_type' => 'page',
        'meta_query' => array(
            array(
                'key' => 'slider',
                'value' => 'home',
                'compare' => '='
            )
        )
     );
    $featuredQuery = new WP_Query( $featuredArgs );

    And here you just loop posts returned by the query?

    Thanks, and sorry for the delay in replying.

    I did in a similar way, with a small Options page to hold page IDs togheter with other custom settings 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘url path with children pages of a frontpage static page’ is closed to new replies.