Replace shortcode in substring
I've created these two functions to toggle between the first paragraph of the content and then everything but the first paragraph so when the user selects 'More' it slides out the article smoothly without replacing the first paragraph that's already displayed as the excerpt.
However if there's a shortcode in that text it shows up as the shortcode syntax rather than displaying properly. I understand why it's not displaying but I'd like to replace any shortcodes in the text so just show up as text instead of shortcode syntax wrapped in brackets.
function get_first_paragraph(){
global $post;
$str = wpautop( str_replace( 'src="http://', 'src="https://', get_the_content() ));
$str = substr( $str, 0, strpos( $str, '/p' ) + 4 );
$str = strip_tags($str, 'astrongem');
return 'p' . $str . '/p';
}
function get_the_post(){
global $post;
$str = wpautop( str_replace( 'src="http://', 'src="https://', get_the_content() ));
$str = substr( $str, (strpos( $str, '/p')));
return $str;
}
Topic query-string shortcode php customization Wordpress
Category Web