1

im doing the follow to get the children of the page im currently administrating:

    $args = array(
    'depth' => 0,
    'child_of' => get_the_ID(),
    'title_li' => '',
    'echo' => 0,
);

wp_list_pages($args);

The output is the title of the subpages and it is linked, what i wish to do is to serperate the title and the link so the output would be something like "http://thelink.com title".

Is this possible?

Regards, Emil

2
  • you want to print child pages in custom html ?
    – Noman
    Jul 30, 2015 at 10:05
  • Yes that would be great :D
    – darrrrUC
    Jul 30, 2015 at 10:51

1 Answer 1

2

Here you go, Enjoy

if $post->ID and get_the_ID() same then use $post->ID

global $post;
$currentPageID = $post->ID;

    $Childpages = get_pages('sort_column=menu_order&hierarchical=0&parent=' . $currentPageID . '&exclude=');

foreach ($Childpages as $page){
echo "Child Page ID: ".$page->ID ."<br>";
echo "Child Page Name: ".$page->post_title ."<br>";
}
3
  • Your are a legend sir!
    – darrrrUC
    Jul 30, 2015 at 11:08
  • One more thing, whats is the shorthand for getting the url? as $page->ID gets the ID what would i type to get the url of that page?
    – darrrrUC
    Jul 30, 2015 at 11:16
  • Sorry for spamming, Did this to get the url: echo get_page_link($page->ID); probably not the easy way but "good enough" :)
    – darrrrUC
    Jul 30, 2015 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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