• Can someone see something wrong with this code?

    I cannot get the output to spit out just the category name. Instead it spits out something like 0″value=”3

    Here is the code and I hope someone can help me:

    This is the code in the functions.php and below this is the form:

    $cat = wp_dropdown_categories(‘orderby=id&order=ASC&hide_empty=0&echo=0’);
    $cat = str_replace(“\n”, “”, $cat);
    $cat = str_replace(“\t”, “”, $cat);
    $cat = str_replace(“<select name=’cat’ id=’cat’ class=’postform’ ><option value=\””, “”, $cat);
    $cat = str_replace(“</option><option value=\””, “_”, $cat);
    $cat = str_replace(“\”>”, “-“, $cat);
    $cat = str_replace(“</option></select>”, “”, $cat);

    $cat = explode(“_”, $cat);
    foreach($cat as $category)
    {
    $category = explode(“-“, $category);
    $cat_number = $category[0];
    $cat_name = $category[1];
    update_option(“cat$cat_number”, $_POST[“cat$cat_number”]);
    } //foreach
    echo “<div id=\”message\” class=\”updated fade\”><p>Your settings have been saved.</p></div>”;
    }

    <label for=”postcats”>Category:<span>*</span></label>
    <?php
    $cats = wp_dropdown_categories(‘orderby=name&order=ASC&hide_empty=0&echo=0’);
    $cats = str_replace(“\n”, “”, $cats);
    $cats = str_replace(“\t”, “”, $cats);
    $cats = str_replace(“<select name=’cat’ id=’cat’ class=’postform’ ><option value=\””, “”, $cats);
    $cats = str_replace(“\”>”, “-“, $cats);
    $cats = str_replace(“</option><option value=\””, “_”, $cats);
    $cats = str_replace(“</option></select>”, “”, $cats);

    echo “<select name=\”postcats\” id=\”postcats\”>\n”;
    $cats = explode(“_”, $cats);
    foreach ($cats as $catsss) {
    $catsss = explode(“-“, $catsss);
    $cat_id = $catsss[0];
    $cat_name = $catsss[1];

    echo “<option value=\”$cat_id\”>”;
    echo $cat_name;
    echo “</option>\n”;
    }
    echo “</select>”;

    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Invalid category outpu’ is closed to new replies.