I have an array of categories, some with an & i.e. events & entertainment.
My script imports these categories and gets the ID of each using its name.
i.e.: $cat_id = array(get_cat_id($linearray[0]),get_cat_id($linearray[1]),get_cat_id($linearray[2]),get_cat_id($linearray[3]));
My script then adds a post to wp using these category ID's.
My problem is that categories from my import with the & are not imported.
These same categories (when an email notice is sent) break the email at the &.
Is there a simple workaround to this?
views:
127answers:
1
A:
When you are writing post, instead of &
you can write &
there and it will be translated to &
without any problems.
Also you could use the str_replace
function to convert that to &
eg:
$new_text = str_replace('&', '&', $your_string);
Sarfraz
2010-05-01 12:02:22
unfortunately there are hundreds of existing 'permalinked' categories.. and this issue relates to an import that adds itself to them.
InnateDev
2010-05-01 12:04:20
@InnateDev: That should not happen though, because wordpress automatically converts them to html entities. That's strange.
Sarfraz
2010-05-01 12:06:23
will this be able to match the actual category name using the get_cat_id function: get_cat_id('Events
InnateDev
2010-05-01 12:13:57
yes this works: $catname_one = str_replace(' $catname_two = str_replace(' $catname_three = str_replace(' $catname_four = str_replace(' $cat_id = array(get_cat_id($catname_one),get_cat_id($catname_two),get_cat_id($catname_three),get_cat_id($catname_four)); print_r($cat_id);
InnateDev
2010-05-01 12:17:10
@InnateDev: It is good news then :)
Sarfraz
2010-05-01 12:20:18