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.


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().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy