Skip to:
Content
Pages
Categories
Search
Top
Bottom

need help with get_all_page_ids function

  • @anointed

    Participant

    I’ve been trying to find a function that will output an array of all my page id’s, so I can manipulate it later.

    What I found was:

    function get_all_page_ids() {
    global $wpdb;

    if ( ! $page_ids = wp_cache_get('all_page_ids', 'posts') ) {
    $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
    wp_cache_add('all_page_ids', $page_ids, 'posts');
    }

    return $page_ids;
    }

    When I add

    $test = get_all_page_ids();
    echo $test

    I end up with an empty array.

    I’m guessing I have either the wrong function or I’m doing something really stupid…. any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • @sbrajesh

    Participant

    you should use

    print_r($test);
    // or

    var_dump($test);

    `

    Not echo, echo will always show empty array for arrays.

    @djpaul

    Keymaster

    This is nothing to do with BuddyPress; this should go on the WordPress forums.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘need help with get_all_page_ids function’ is closed to new replies.
Skip to toolbar