WordPress.org

Ready to get started?Download WordPress

Forums

get_permalink or wpautop adding mysterious line break (1 post)

  1. Michelle
    Member
    Posted 3 years ago #

    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>
    &nbsp;»
    </p>

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by Michelle
  • This topic is not resolved
  • WordPress version: 3.1-2-17229