• I would like to add text to the output of the permalink. I have various categories and to every category belongs a second “special”-category. So every category should have a link to its own special-category. I thought the solution could be quite easy, something like this:

    <a href="<?php echo get_permalink('); ?>-special">Link</a>

    But it cuts the permalink off. I tried other variations, but got no result. Is there any way to get it solved to add a text on the output?

    Thanks in advance,

    benraaa

Viewing 2 replies - 1 through 2 (of 2 total)
  • where are you using that code?
    https://codex.www.ads-software.com/Function_Reference/get_permalink

    it cuts the permalink off

    the error might be caused by the single quote in the brackets:

    (')

    unless this was just a typing mistake (?)

    Thread Starter benraaa

    (@benraaa)

    Yes, sorry, the single quote was a typing mistake. Meanwhile I tried a lot of variations: inside and outside the loop, with get_permalink(), the_permalink() and post_permalink(), with an echo-command for the text an with variables. It’s definitly the wrong way. Now, when I tried it once more, it didn’t cut it off, but shows the link of the last article of the category page (now indeed together with the “special” text). However I need the link of the category page where I put the code.

    To make it more clear:

    code is on category.php,
    last article shown on page “weather” is e.g. “A mix of sun and clouds”,
    link shows https://www.domain.com/weather/a-mix-of-sun-and-clouds-special,
    but should be https://www.domain.com/weather-special

    Is there any other method to get the right link?

    Hope it’s not too confusing.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add text to get_permalink()’ is closed to new replies.