Support » Fixing WordPress » HowTo translate this IF Clause?!

  • Hello WPers,

    I have an problem to solve my IF clause. I need to input something in my template that would in simple language be:

    IF current page IS child page OF IDX {….

    Anybody get a clue how to solve this?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • This check should do it – Each page has the parent page id stored as an attribute:

    if ($post->post_parent == $id_of_parent_page)
    {
    ...
    }

    Hm thanks for the Tip but I need to declare this in the header. I got some special CSS and a Gallery and only when a subpage of the Galery(ID13)is loaded WP should output the correct CSS…

    example (this is how it is solved now):

    <style>
    <?PHP
    if (is_page(‘Galerie’) or is_page(‘Landscape’) or…{
    echo ‘body { … }’;
    } else {
    echo ‘body { … }’;
    }
    /?> </style>

    But this means for ever subpage I must edit my headerfile and include another “or is_page…” – this should be solved somehow else in clear language it would be:

    IF current page IS child page OF galerie { …. }

    I think the Vars you gave me are from the loop aren’t they? I tried to echo them but theres no output?!

    Ok, if you want to run this if check outside the loop you want something like this:

    <php
    if (is_page() && $posts[0]->post_parent == $id_of_parent_page)
    {
    //do style stuff here.
    }
    ?>

    This checks that we are on a page and then uses the global array of posts to look at the page (post 0 in this single post query) and check the value set for post_parent.

    Hope this helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘HowTo translate this IF Clause?!’ is closed to new replies.