Viewing 3 replies - 1 through 3 (of 3 total)
  • jack randall

    (@theotherlebowski)

    you may need to explain what you’re actually trying to do as that’s exceptionally vague…

    Thread Starter celticks

    (@celticks)

    I am trying to have it so if a page is a child of a certain page to display something there.

    something along the lines of:
    if (parent=Testimonials)
    get_template_part( ‘loop’, ‘testimonials’ );
    }

    Assuming the page id of Testimonials is 123, then use

    if ( 123 == $post->post_parent ) ...

    See http://codex.wordpress.org/Function_Reference/get_post for other properties of the current post that you can reference in the same way.

    Note 1: You can use a plugin to display the page id – e.g. Reveal IDs or simply hover over the edit link in the All Pages screen and the ID will show up in the edit URL.

    Note 2: If you want to use the page slug (e.g. ‘testimonials’) instead of the ID, see the example http://codex.wordpress.org/get_posts#Get_a_post_by_its_slug but change “‘post_type’ => ‘post’,” to “‘post_type’ => ‘page’,”.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I say: if parent = _____ then _____’ is closed to new replies.