Support » Fixing WordPress » How to link entire excerpt?

  • Good day people…

    Hope you can help me. I need to know which kind of code I have to use to link the entire excerpt instead of just the title? I tried to convert at least the “read more” tag as a link with this code at the functions of my template:

    <?php
    $themeOption = new themeOptions();
    
    //function to replace invalid ellipsis with text linking to the post
    function elpie_excerpt($text)
    {
       return str_replace('[...]', '<a href="'. get_permalink($post->ID) . '">' . ' [&hellip; Mas Info]' . '</a>', $text);
    }
    add_filter('the_excerpt', 'elpie_excerpt');?>

    It worked, but in the backend an error with the headers was affecting my site so I removed it.(Warning: Cannot modify header information)

    My primary idea was to create a div tag wrapping the entire excerpt loop and linking it to the post.. but I dont know where or how to do it.

    If is not too much to ask, I would like somebody to guide me. Thank you so much in advance and happy holy days to y’all.

Viewing 1 replies (of 1 total)
  • It sounds like your working solution was fine. The “Cannot modify header information” error was most likley due to blank spaces in your functions.php file, make sure your new function doesn’t have empty lines/whitespaces above or below it.

Viewing 1 replies (of 1 total)
  • The topic ‘How to link entire excerpt?’ is closed to new replies.