• I am creating an options page for a site I am building and I have hit a problem that I have not noticed before and that is when selecting a category that has an ampersand (&) in the category name it will not show the correctly selected category when going back to the options page.

    Is there a way around this?
    I have tried using & but i guess as it contains the & it still errors.

    This is for an options page, so I am using:

    $categories_list = get_categories('hide_empty=0');
    
    $categories = array();
    foreach ($categories_list as $catlist) {
    	$categories[$catlist->cat_ID] = $catlist->cat_name;
    }
    array_unshift($categories, "Choose a category");

    then

    case 'select':
    ?>
    
    <div class="tfh_input tfh_select">
    	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
    
    <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
    <?php foreach ($value['options'] as $option) { ?>
    		<option <?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?>
    </select>
    <small><?php echo $value['desc']; ?></small>
    	<div class="clearfix"></div>
    </div>
    <?php
    break;

    which i think is pretty standard?

    Any ideas on how i can around this so it still works with the ampersand in the category name or is this a bug?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I would be interested in knowing what can be done to troubleshoot this issue. We are running into the same problem with our Theme Options panel and the custom query in the theme.

    If the category name has an ampersand, the query breaks. I am assuming that this is because it is interpreting the ampersand as code. So, how do we get the data from the Theme Options and convert it into something that won’t break the query?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    IIRC, WordPress escapes the code to & which … is for sanitization/security reasons.

    Looks like https://core.trac.www.ads-software.com/ticket/14584 exists for the general problem.

    Thanks. I figured it was something integral to the application itself.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Yeah, I have the same problems with other web-apps and the & sign

    My example was supposed to be & amp ; – heh.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WordPress 3 ampersand in category name’ is closed to new replies.