• <?php
    /*
    Template Name: Just Show Child URL's
    */
    
    $page_children = get_page_children($post->ID, '');
    
    if (!empty($page_children)) {
    	foreach ($page_children as $child) {
    		echo $child->guid . "\n";
    	}
    }
    ?>

    Why won’t this work ??
    If i put in a wp_list_pages, it works …

    <?php
    /*
    Template Name: Just Show Child URL's
    */
    
    wp_list_pages();
    
    $page_children = get_page_children($post->ID, '');
    
    if (!empty($page_children)) {
    	foreach ($page_children as $child) {
    		echo $child->guid . "\n";
    	}
    }
    ?>

    Help 🙁

Viewing 2 replies - 1 through 2 (of 2 total)
  • Didn’t test to see what your code actually outputs, but wouldn’t you have to echo the $child->guid wrapped in an <a href= type tag?

    Thread Starter tdskate

    (@tdskate)

    Well no,
    Here’s what i really wanted to achieve:

    <?php
    /*
    Template Name: Redirect to Random Sub
    */
    
    get_pages();
    $page_children = get_page_children($post->ID, '');
    $children_count = count($page_children)-1;
    $random_child = rand(0, $children_count);
    $randum_url = ($page_children[$random_child]->guid);
    
    echo header("Location: $randum_url");
    
    ?>

    This is a template that randomly redirects the user to one of the child pages of a parent page. I needed the child url’s in an array and it worked by triggering get_pages();

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘template: just show child uri’s’ is closed to new replies.