using is_page() and child_of= in conditional statement? (4 posts)

  1. syncbox
    Posted 8 years ago #

    2.21, specifically.

    I am wondering if there is a way to use the child_of= parameter in the is_page() function?

    something like:

    if (is_page('child_of=10')) {
    some stuff to do; }
    else {}

    I'm trying to find a way to add the parent page (and its permalink) to the title before the current page's title. Not all pages are child pages, of course.

    I can set up this:

    if (is_page(3)) {
    echo c2c_get_custom('heading-tagline','<h2>Affirmative Action Consulting</h2><p>','</p>','');
    elseif (is_page(10) || (11) || (12) || (13)) {
    the_title('<h2><a href="/consulting-services/" title="Consulting Services">Consulting Services</a>','</h2>');
    echo c2c_get_custom('heading-tagline','<p>','</p>','');
    elseif (is_page(14)) {
    the_title('<h2><a href="/resource-center/" title="Resource Center">Resource Center</a>','</h2>');
    echo c2c_get_custom('heading-tagline','<p>','</p>','');
    else {
    echo c2c_get_custom('heading-tagline','<p>','</p>','');

    but the added "Consulting Services" is added everywhere except on the homepage - weird. If I just use one page in the second if statement (to add Consulting Services) it works as expected, only adding it to the actual page, not others...

    I guess I am wondering why it doesn't work using the standard method of testing for several page ids per my second example.

    any ideas? maybe I am just messing up the syntax or something but I've stared at this and messed with it and cannot see the faults.

  2. wheresitworking
    Posted 8 years ago #

    Did you ever find a solution to this?

  3. marlonl
    Posted 8 years ago #


    (is_page(pageid) || $post->post_parent=="pageid")


    <?php if (is_page('contact') || $post->post_parent=="2")) { ?>

  4. Clicknathan
    Posted 8 years ago #

    Just wanted to confirm that marlonl's solution does work.

Topic Closed

This topic has been closed to new replies.

About this Topic