I am getting the following error notice:

Array to string conversion in /path/to/wp-includes/class-wp.php on line 281

I have a form that is for frontend submissions to create custom post type posts. This form has "add more" group fields generated with jquery:

<fieldset id="education">
        <ul id="edu-group" class="form-fields">
            <li class="layout layout--flush add-more-field group-field">
                <div class="layout__item one-quarter">
                    <label for="institution_0_name" data-pattern-text="Institution +=1">Institution </label>
                    <input type="text" name="institution[0][name]" id="institution_0_name" data-pattern-name="institution[++][name]" data-pattern-id="institution_++_name">
                </div><div class="layout__item one-tenth">
                    <label for="year_0_name" data-pattern-text="Year +=1">Year </label>
                    <select name="year[0][name]" id="year_0_name" data-pattern-name="year[++][name]" data-pattern-id="year_++_name">
                        <?php yearDropDownDesc(1960, date("Y")); ?>
                </div><div class="layout__item one-quarter">
                    <label for="course_0_name" data-pattern-text="Course +=1">Course </label>
                    <input type="text" name="course[0][name]" id="course_0_name" data-pattern-name="course[++][name]" data-pattern-id="course_++_name" >
                </div><div class="layout__item one-quarter">
                    <label for="grade_0_name" data-pattern-text="Grade +=1">Grade </label>
                    <input type="text" name="grade[0][name]" id="grade_0_name" data-pattern-name="grade[++][name]" data-pattern-id="grade_++_name">
                </div><div class="layout__item one-tenth">
                    <button type="button" class="btn btn--small btn--remove">-</button>

           <button type="button" class="btn btn--icon btn--small btn--addmore">Add +</button>


Only when I add these fields the error notice happens.I believe this is because of name attributes being institution[0][name] etc although I am not sure why looking at line 281 of the class-wp.php

I have tried setting query_var to false for the custom post type but that didn't work. Can anyone shed light on this?

1 Answer 1

<select name="year[0][name]" id="year_0_name" ...

The variable "year" is a variable already used by the WordPress query system.

Take a look at the top of the file where you see "$public_query_vars" to see the ones WordPress is already using and expecting to be something different than what you're sending to it.

Use different variable names than those. I would recommend prefixing all your variable names with something unique to your specific case, so as to avoid these sort of conflicts.

  • Oh man, I was reading the codex about query_vars and I just figured it out. Came to close thread. Thanks so much. D'oh!
    – CKJ
    Sep 17, 2014 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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