WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i want to add a link to the first post of every WP blog that i have. For example this simple function adds the link to every post.

    function add_link($link){

    $link .= '<a href="http://site.com">Link</a>';
return $link;

so basically instead of the link showing below each post, I want it to show only at the bottom of the first post only.


share|improve this question
Still not solved? – toscho Oct 6 '12 at 22:09
not yet... thanks. – Ronny Oct 7 '12 at 19:30
up vote 2 down vote accepted

Just remove the filter when it is called the first time:

function add_link($link)
    // this will guarantee the filter will not be called again.
    remove_filter( current_filter(), __FUNCTION__ );
    return $link . '<a href="http://site.com">Link</a>';
share|improve this answer

Trivial with some basic logic

Add before your function:

$added = false;

Then check e.g.:

    if(!$added ){
        $added = true;
        $link .= '<a href="http://site.com">Link</a>';
share|improve this answer
I think you mean if (!$added). Also it's not really clear where this $added variable is scoped. @toscho's answer is much cleaner. – David John Smith Jan 20 '13 at 3:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.