Support » Themes and Templates » Something like parent_is(‘4’)

  • Does someone have a solution for the following problem?
    I’am trying to make some pages different based on whether there parent page is (for example) page 4. However there is not such thing as a parent_is('4') function in the Conditional_Tags list on . Did I overlooked something or is the only solution hard-coding all child-pages of page 4?


Viewing 4 replies - 1 through 4 (of 4 total)
  • Parent “Page” or parent “category”? I’d like to know how to do this with parent category — something like is_category_parent(). Or the reverse, if there was a way to say that it is the child of a category — like is_category(child=10).

    Well it is ‘parent Page’ in my case.

    If all you want is a quick fix and your problem is limited to being able to include children of a parent category when testing for is_category(), you could do this:

    Check functions.php inside /wp-includes/ and around line 1295 you’ll see the function that actually does the is_category test. It begins:

    function is_category ($category = '') {

    and then proceeds to do a number of tests. I added one more test:

    else if ($category == $cat_obj->category_parent) {
    return true;

    That way, I can have a conditional tag that will result in “true” if a post or posts are either in a category or in a child of said category.

    This may not be of use to you, but, after lurking on these boards for too long, I thought I’d start sharing some of the things we’ve been doing to get around the understandable limitations of this Blog-turned-CMS called WordPress.


    Thought I’d note that WordPress hasn’t made any turns. WordPress may be a blogging system with CMS-like features, but it is for blogs first and foremost.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Something like parent_is(‘4’)’ is closed to new replies.