Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm getting image fields wrapped in tags and would like to remove the surrounding divs, but only if they are of class "mceTemp". Anyone know of an efficient way to do this?

Also, should those Divs even be there?

share|improve this question
    
So I wrote a recursive function which sort of works: –  codecowboy Oct 14 '10 at 9:01
    
function recursive_replace($string) { preg_match('/<div class\=[\"]mceTemp[\"]\>(.*?)<\/div>/si',$string,$matches); if($matches) { $string = preg_replace('/<div class\=[\"]mceTemp[\"]\>(.*?)<\/div>/si','$1',$string); recursive_replace($string); } else { return $string; } } –  codecowboy Oct 14 '10 at 9:02
    
feel free to improve on it! –  codecowboy Oct 14 '10 at 9:02
    
Normally you should not run over those as tinymce removes them on it's own. –  hakre Oct 14 '10 at 21:00
    
I'm wondering if the plugin custom field templates is the culprit. Someone installed this and made a mess of it. –  codecowboy Oct 14 '10 at 21:56

1 Answer 1

up vote 1 down vote accepted

I agree with hakre - something funky is going on elsewhere, those shouldnt be appearing.

As a sidenote, you could use the jQuery unwrap() function to remove those divs.

jQuery('div.mceTemp img').unwrap();

http://api.jquery.com/unwrap/

share|improve this answer
    
cool. That is good to know ;-) –  codecowboy Oct 19 '10 at 10:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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