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 have been doing some research on this but can't get a handle on the exact code I need to do this.

I am using a wordpress content slider that strips out <ul></ul> and <li></li> tags. But it recognizes and allows me to style <dl> and <dt><dd> tags.

I need to write a wordpress filter in my functions.php file to do this for only the category used in the slider (these posts are hidden and the slides will be linked to other pages).

So I need to get the "content" for posts inside category id 7 and replace <ul> with <dl> and <li> with <dt><dd>, and of course the same for the closing tags.

This will allow for use of the list features of the post editor without the need to edit the html.

Any help is appreciated.

share|improve this question

migrated from stackoverflow.com Jul 17 '11 at 11:43

This question came from our site for professional and enthusiast programmers.

1 Answer 1

Just put an in_category() conditional around your content-filtering code, wrap the whole thing in a function, and hook it into the the_content filter:

function mytheme_filter_cat_7_content( $content ) {
    if ( in_category( '7' ) ) {
    // filter your content here
    }
// then return $content
return $content;
}
add_filter( 'the_content', 'mytheme_filter_cat_7_content' );

(Just put whatever code you're using to filter the_content inside the conditional.)

Also, note that you can pass either a category ID or slug to in_category().

share|improve this answer

Your Answer

 
discard

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