WordPress.org

Ready to get started?Download WordPress

Forums

Redirect to random child page (4 posts)

  1. tdskate
    Member
    Posted 6 years ago #

    I need to fix this template code so it sends a visitor a php header with random child page location.

    <?php
    /*
    Template Name: Redirect to Random Sub
    */
    
    echo wp_list_pages('child_of='.$post->ID.'&title_li=');
    
    /* header('Location: '); */
    ?>

    Thx.

  2. JeremyVisser
    Member
    Posted 6 years ago #

    It doesn't have the ability to limit itself to child pages, but the Redirection plugin can do random redirects.

  3. tdskate
    Member
    Posted 6 years ago #

    I just need a tag or function that can create an array with urls from a page's children.. does this question even make sense ?

  4. MichaelH
    Member
    Posted 6 years ago #

    Might try this untested code to get an array of IDs for pages with parents

    $pageswithparents = $wpdb->get_results("SELECT ID
       FROM $wpdb->posts
       WHERE post_type = 'page'
       AND post_parent > 0");

    Gleaned from http://codex.wordpress.org/Function_Reference/wpdb_Class

Topic Closed

This topic has been closed to new replies.

About this Topic