Link to home
Create AccountLog in
Avatar of Eroots
ErootsFlag for United States of America

asked on

Stop wordpress the_excerpt() from stripping CSS.

I am using wordpress to pull an excerpt from a specified page into a home template. It's stripping off the CSS and I need it to just show normally, is there any way to do that?

I have included my code below.

<?php 
$args=array(
   'post_type'=>'page',
   'post__in' => array(19)
);
$the_query = new WP_Query($args);
// custom Loop
while ($the_query->have_posts()) : $the_query->the_post();
// the excerpt of the page
if (function_exists('the_excerpt_reloaded'))
the_excerpt_reloaded(100, '', 'content', FALSE, '', '', '1', '');
else the_excerpt(); // this covers Advanced Excerpt as well as the built-in one
endwhile; // end custom Loop
?>

Open in new window

Avatar of coredatarecovery
coredatarecovery
Flag of United States of America image

create a custom css file for that template php file for your excerpts.
Avatar of Sam Cohen
just use a shortcode plugin.And post the excerpt anywhere you want to!!!
instal the plugin: Shortcode Generator

Avatar of Eroots

ASKER

Neither of these are viable for me.

As noted, the_excerpt() is stripping out ALL of the CSS, so using a custom CSS file for the template does not work, since the_excerpt() strips out all of the class tags from the_excerpt, IE H1, H2, <br />, <span> etc....

As well, I am not having trouble pulling the code, just having the CSS stripped, so using shortcodes will not help either.

I need regular user levels to be able to edit the style of the_excerpt() being pulled in via the tinyMCE WYSIWYG editor.
ASKER CERTIFIED SOLUTION
Avatar of jrm213jrm213
jrm213jrm213
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Eroots

ASKER

thanks for the reference link, we ended up using a different method (separate pages for "excerpt" and main post), but this will be useful for the future.