problem with style and Excerpt

Hello all ,

i got problem with Excerpt since i can t have any paragraph formatting, so my except look like one long paragraph without any line breaks.I searched the web , try some settings like add “

” in strip retags but no go and i copy the code here: maybe i shoudl change the last line but really dunno.

`add_filter(‘the_excerpt’, ‘home_excerpts’);

function home_excerpts($content = false) {

        global $post;

        $mycontent = $post->post_excerpt;



        $mycontent = $post->post_content;

        $mycontent = strip_shortcodes($mycontent);

        $mycontent = str_replace(']]>', ']]>', $mycontent);

        $mycontent = strip_tags($mycontent, '<p>' );

        $excerpt_length = 10;

        $words = explode(' ', $mycontent, $excerpt_length + 1);

        if(count($words) > $excerpt_length) :

            array_pop($words);

            array_push($words, '...');

            $mycontent = implode(' ', $words);

        endif;

        $mycontent = '<p>' . $mycontent . '</p>';

`thx for any help , i am lost :frowning:

I’m not entirely sure what you are asking, but I used the following code to recall something typed in a textbox with the linebreaks intact:

[php] <?php
echo “

”;
$quote_style = ENT_QUOTES;
$bio = html_entity_decode($user[‘blurb’], ENT_QUOTES);
echo nl2br($bio);
echo “

”;
?>
[/php]

Take a look at the nl2br function and see if it can help you out. http://php.net/manual/en/function.nl2br.php

Thx for the answer but i found it at the line = strip_tags, I had to add every tag i need to keep the paragraph html for the trailer ( Excerpt) , i just add , ‘

  • ’ at it so exactly like this:

    $mycontent = strip_tags($mycontent, ‘

    • ’ );

      of course if you need some span , br or else just add them :slight_smile:

      thx for help anyway :slight_smile:

      cheers
      Oli

Thanks for posting your solution. Helps me out when I run into this problem and am searching the forum. ;D

Sponsor our Newsletter | Privacy Policy | Terms of Service