function add_meta_tags() { global $post; if ( is_single() ) { $meta = strip_tags( $post->post_content ); $meta = strip_shortcodes( $post->post_content ); $meta = str_replace( array("\n", "\r", "\t"), ' ', $meta ); $meta = substr( $meta, 0, 125 ); $keywords = get_the_category( $post->ID ); $metakeywords = ''; foreach ( $keywords as $keyword ) { $metakeywords .= $keyword->cat_name . ", "; } echo '' . "\n"; echo '' . "\n"; } } add_action( 'wp_head', 'add_meta_tags' , 2 );