Illegal String Offset Error

Home Forums WPAlchemy Illegal String Offset Error

This topic contains 0 replies, has 1 voice, and was last updated by  DesignUtensil 10 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2713

    DesignUtensil
    Participant

    I am building a site for a pizza restaurant. In the WP backend I have a custom post type for Menu Items, and in there I have categories like pizza-menu, salad-menu, sandwiches-menu, etc. Originally I had the category Menu, then all those were set as Parent: “Menu”.

    I used WP Alchemy to create meta boxes for the menu items page, so the user can input an item description and price (2 boxes, first one is a text area, second is an input type=’number’).

    Everything was working great. On the menu page, it looks like this:

    <?php query_posts( array ( ‘post_type’ => ‘menu_item’, ‘category_name’ => ‘pizza-menu’, ‘orderby’ => ‘date’, ‘order’ => ‘asc’ ) ); ?>

     

    <section class=”pizzas”>

     

    <h1>Pizzas</h1>

     

    <h2>All pizzas are hand-made to order, baked in our Washington-sourced fruit-wood fired oven. Approximately 13″ and sliced in sixths.</h2>

     

    <table>

     

    <?php while (have_posts()) : the_post(); ?>

     

    <?php $meta = $custom_metabox->the_meta(); ?>

     

    <tr>

     

    <th>

     

    <h3><?php echo get_the_title(); ?>

     

    <span><?php echo $meta['description']; ?></span>

     

    </h3>

     

    </th>

     

    <td><? echo $meta['price']; ?>.00</td>

     

    </tr>

     

    <?php endwhile;?>

     

    </table>

     

     

    </section>

     

    This was working perfectly, until I was having issues on another page echoing the string of the sub-category, like ‘pizza-menu’ or ‘sandwiches-menu’. So I said, “Hey, it’ll be easier without the main and child categories, I should just take out the Menu category!” So I did. And it broke EVERYTHING.

    No, I didn’t have a backup.

    I finally wrangled everything back in, but now the weirdest thing happens. It will show the FIRST pizza item perfectly, but everyone after that shows the title, but nothing else. I turned on debugging, and it says this:

    Warning: Illegal string offset ‘description’ in ~/wp-content/themes/(Theme Name)/menu-page.php on line 19

    Line 19 is this:

    <span><?php echo $meta['description']; ?></span>

    I don’t know why it’s fine for the first item, then everything goes to shit after that. If I take line 19 out, it just gets caught on the next line that pulls a $meta['value'].

    It works perfectly for the “Salads” section, which uses the SAME code, just changing the category_name in the initial query.

    If anyone knows the source of this issue, it would save me grey hairs and cranial injuries from banging my head on the table after struggling with this all day long. Thank you in advance for helping out!

    • This topic was modified 10 months ago by  DesignUtensil.
    • This topic was modified 10 months ago by  DesignUtensil. Reason: Code Formatting
    • This topic was modified 10 months ago by  DesignUtensil.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.