0

im trying to get just first paragraph from about page to home page went through some code on internet but didnt help at all

function get_first_paragraph(){
global $post;
$str = wpautop( get_the_content() );
$str = substr( $str, 0, strpos( $str, '</p>' ) + 4 );
$str = strip_tags($str, '<a><strong><em>');
return '<p>' . $str . '</p>';
}
<?php echo get_first_paragraph(); ?>
  • what is the result? – Michael Jul 10 '19 at 2:42
  • getting nothing in output,its blank.... – syner Jul 10 '19 at 3:31
  • And is the global $post variable already set to your About page? What does the get_the_content() function return? – Krzysiek Dróżdż Jul 10 '19 at 9:22

Your Answer

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

Browse other questions tagged or ask your own question.