Add css only if there is a shortcode.

Posted in: Newsmag
Post count: 199

Hello, a question: I want to change the css only when the shortcode is active. Using this function:

add_filter('the_content', 'custom_category_text');
function custom_category_text( $content ) {
global $post;
$cats = array( 2815, 1966, 1967, 1968, 4227, 1969, 4581, 1970, 1971, 1972, 1974, 1975, ); //cat IDs for which to append content
$text = '[pro_ad_display_adzone id="171616" background="1" container="skin"]';
$post_cats = wp_get_post_categories( $post->ID );
if( in_array( $post_cats[0], $cats )) $content .= do_shortcode( $text );
return $content;
}

i entered a shortcode in some articles.

I wish this CSS was when shortcode is active:

.td-header-header {
padding-top: 200px;
}

Is possible?

Post count: 6600

Hi,

Not sure, I’m not aware of a way doing this. You need custom work for this so I suggest you find a freelancer to help you do it if you really need it and don’t know how to: http://studio.envato.com/

Thanks

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newsmag’ is closed to new topics and replies.