0

I have a landing page that pulls in an excerpt, title and thumbnail of its children. It works, except the title (which is the page title) link is doubling up the parent folder in the url it creates. like this: www.site.com/restaurant/restaurant/mcdonalds. I'm not great at PHP and I can't figure out why it's doubling on the title and not the thumbnail. How can i alter this to only pull in the parent once?

  if ( is_page( 'restaurants' ) ) {
                    $pageChildren = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'hierarchical' => '0', 'exclude' => '1453' ) );
                    if ( $pageChildren ) {
                    foreach ( $pageChildren as $pageChild ) {
                    echo '<div class="restaurant-landing"><h2><a href="' . get_page_uri($pageChild) .'">' . $pageChild->post_title . get_the_post_thumbnail($pageChild->ID).'</a></h2>';
                    if ($pageChild->post_excerpt){
                    echo '<p>'.$pageChild->post_excerpt.'</p></div>';
                    }
                    }
                    }
                }
1

if you look into the html in the browser, you should see that the function is outputting a relative link uri;

is there any reason why you are trying to use get_page_uri() instead of get_permalink() ?

  • you know what.. you're right. I don't know. that totally worked. :) Thank you! – jamie Oct 29 '12 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.