I'm trying to get post's permalinks outside of the loop via a wordress plugin. Nothing seems to be working. Here is the original code that does not link to any permalink.
public function get_comments_count($single){
if (isset($this->params['comments']) && $this->params['comments'] == 'yes'){
return '<div id="disquscomments"><a href="'.$permalink.'#disqus_thread">Comments</a></div>';
} else {
return null;
}
}
To get the comments linking to the permalink, I tried adding echo get_permalink within the href link, like so..
public function get_comments_count($single){
if (isset($this->params['comments']) && $this->params['comments'] == 'yes'){
return '<div id="disquscomments"><a href="<?php echo get_permalink($post->ID); ?>#disqus_thread">Comments</a></div>';
} else {
return null;
}
}
This just returned the link as mysite.com/< ? php echo get_permal... So, I then tried setting a function for permalink and putting it in the href link.. I did this like so...
public function get_comments_count($single){
$permalink = get_permalink($post->ID);
if (isset($this->params['comments']) && $this->params['comments'] == 'yes'){
return '<div id="disquscomments"><a href="'.$permalink.'#disqus_thread">Comments</a></div>';
} else {
return null;
}
}
Unfortunately, this did not work. It just returned the link as mysite.com/#disqus_thread without the actual permalink.
I have no idea why this isn't working. :( Any help would truely be appreciated, and if you would like me to paste the full plugin code via pastebin, I gladfully will! Please help a bro out!! :)
get_comment_count
or something else?