Skip to content

Instantly share code, notes, and snippets.

@ashleyfae
Created December 1, 2015 20:21
Show Gist options
  • Save ashleyfae/7d013ab3ead0988c2f25 to your computer and use it in GitHub Desktop.
Save ashleyfae/7d013ab3ead0988c2f25 to your computer and use it in GitHub Desktop.
<?php
/*
* Plugin Name: Comment Link After Post
* Plugin URI: https://www.nosegraze.com/questions/comment-link-below-post/
* Description: Adds a link to the comment area below the post.
* Version: 1.0
* Author: Nose Graze
* Author URI: http://www.nosegraze.com
* License: GPL2
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: comment-link-after-post
* Domain Path: /languages
*
* @package comment-link-after-post
* @copyright Copyright (c) 2015, Ashley Evans
* @license GPL2+
*/
/**
* Adds a comment link after the post content.
*
* @return string
*/
function comment_link_after_post( $content ) {
ob_start();
?>
<div class="comment-link-after-post">
<a href="<?php comments_link(); ?>">Click here to leave a comment!</a>
</div>
<?php
return $content . ob_get_clean();
}
// You can change the number 10 to adjust the priority (when this gets added to the content).
add_filter( 'the_content', 'comment_link_after_post', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment