Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

It's not hard i think, but i run out of ideas...

In template file I have code like this;

$current = $post->ID;
$parent = $post->post_parent;
$pages = get_pages('child_of='.$parent.'&parent='.$parent.'&sort_column=post_title&title_li&hierarchical=0');
$front_id = get_option('page_on_front');

I cant figure out how will statement to determine if $front_id is in $pages array look like !

thx for Your time!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

If you just need to remove, or ignore, it from $pages, use the exclude argument instead;

$pages = wp_list_pages( array(
    'exclude' => get_option( 'page_on_front' ),
    'child_of' => $parent,
    'parent' => $parent,
    'sort_column' => 'post_title',
    'title_li' => '',
    'hierarchical' => '0'
) );

I've used wp_list_pages as I assume this is the function you've intended to use (get_pages does not have a title_li argument).

If that isn't what you were after, then just loop over the pages to determine if it's there;

foreach ( $pages as $page ) {
    if ( $front_is_here = ( $page->ID == $front_id ) )
        break;
}

if ( $front_is_here ) {
    // front page is among pages
} else {
    // front page is *not* among pages
}
share|improve this answer
    
the second code example is the answer ^^ –  wolf3d Aug 11 '11 at 19:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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