Support » Fixing WordPress » get_permalink or wpautop adding mysterious line break

  • Hi and thanks in advance for any help you can give me! I have a mysterious issue.

    The following code works exactly as expected. It spits out a custom Description field which includes formating etc exactly as it was originally inserted into my meta box, then at the end of the last line adds a “Learn More” link.

    <?php echo wpautop($meta['station_description'] . '&nbsp;&nbsp;<a href="/fake-link">Learn more</a>&nbsp;&raquo;'); ?>

    When I change that fake link to use get_permalink, however, it adds a line break before spitting out the Learn More. Not a br tag, not a new p tag, just a line break that shows in the code and on the page. Here’s the code:

    <?php echo wpautop($meta['station_description'] . '&nbsp;&nbsp;<a href="' . get_permalink() . '">Learn more</a>&nbsp;&raquo;'); ?>

    This is how it displays:

    The description text goes here yadda yadda yadda.
    Learn more

    Does anyone have any clue what would cause this and/or how to fix it? Thanks so much!!

    And when viewing output HTML:

    <p>The description text goes here yadda yadda yadda.&nbsp;&nbsp;
    <a href="http://localhost/full-link/posturl/">Learn more</a>
  • The topic ‘get_permalink or wpautop adding mysterious line break’ is closed to new replies.