0

I purchased a Wordpress theme, for a restaurant.

The theme uses Posts for each (food)menu entry, and Categories to segment the menu into sections.

The theme is built for 1 level hierarchies. e.g:

>Menu
>>>Breakfast
>>>Lunch
>>>Dinner

However, the restaurant I am working for has a more complex menu:

>Menu
>>>Breakfast
>>>>>>Food
>>>>>>Sides
>>>>>>Drinks
>>>Lunch
>>>>>>Small
>>>>>>Large
>>>>>>Sides

Here is the original index.php

Here is my modified index.php, which attempts to iterate first within the 1st level of categories (e.g. Breakfast, Lunch...), and then through all 2nd level categories (e.g. Breakfast > Food, Breakfast > Sides...).

In both, $menuCat refers to the "Menu" parent category.

This is the live site, using a child theme, and the new index.php. It manages to find the "Lunch" category, but not the "Breakfast" category, and it doesn't output the subcategories.

I receive a PHP exception:

Warning: Illegal offset type in isset or empty in /.../wp-includes/taxonomy.php on line 1236

Here is taxonomy.php from line 1234:

if ( $parent ) {
    $hierarchy = _get_term_hierarchy($taxonomies[0]);
    if ( !isset($hierarchy[$parent]) )
        return $empty_array;
}

So, it seems the $hierarchy of the parent is not not set. I don't know what this means.

| improve this question | | | | |
1

on line 59, parent is expected to be an integer, you're passing an object:

$args = array(
    'orderby' => 'slug',
    'order' => 'ASC',
    'parent' => $category // <---- here
);

it should be $category->term_id

| improve this answer | | | | |
  • Thanks Milo! It's now working, except it is only displaying the "Lunch" category, and not the "Breakfast, Dinner or Dessert" categories. – Steve Jun 14 '13 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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