Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hello guys I would like to append a link to the end of the content within my post. I currently have this in my functions.php file:

function ifcj_comment_link() {
global $post;
return ' <a href="'. get_post_meta($post->ID, 'Israel In The News Audio Link', true) . '">' . __( '<div id="audio-player">Testing</div>', 'ifcj' ) . '</a> ';
}

function ifcj_custom_excerpt_more( $output ) {
if ( has_excerpt() || in_category( _x('israel-in-the-news', 'israel-in-the-news category slug', 'ifcj') ) &&! is_attachment() ) {
    $output .= ifcj_comment_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'ifcj_custom_excerpt_more' );

It displays just fine in my categories feed page: http://stage.standforisrael.org/category/israel-in-the-news/feed

But that particular link is not showing up on the archive.php page.

Am I missing something here?

Thanks

share|improve this question
    
Don't forget to use esc_attr/esc_url on that href –  v0idless Oct 21 '11 at 20:59

1 Answer 1

up vote 0 down vote accepted

The excerpt must be used by the Theme. I don't think it is. Use 'the_content' filter to append to the post. Excerpts are usually used in feeds and only by certain themes.

add_filter('the_content', function($content){
    if(!is_archive()) return $content;
    global $post; // This is the current output post
    ob_start();
    // Echo stuff to append to post here! (your link or whatever)
    return $content.ob_get_clean();
});

PHP 5.3 Closure used. Extract function yourself aside for PHP 5.2.

Regards.

share|improve this answer

Your Answer

 
discard

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.