I have the following code in my functions.php file to display post shortlink in my posts (I prefer not to edit theme files if possible)...
function add_post_content($content) {
if ( is_single() ) {
$content .= '<p>Shortlink: ' .wp_get_shortlink(); '</p>';
} elseif ( 'portfolio' == get_post_type() ) {
$content .= '<p></p>';
}
return $content;
}
add_filter('the_content', 'add_post_content');
The wp_get_shortlink function doesn't work with custom post types (I understand). I have 1 custom post type and so I am trying to stop it running on that post type but is does - just displays 'Shortlink: ' (because the function doesn't work it doesn't actually display anything else). Can anyone help me with either a way to display the custom post shortlink or edit my code to stop it showing the words 'Shortlink: '?
As an aside, would it be possible to edit the code so that the shortlink is displayed in a form textbox? I tried but couldn't get it working. Many thanks.
I've left what I have active. You'll see the output at the bottom of the pages. The second link is is the custom post type...
http://skipology.com/iphoneography-feature-puddles-featured-by-eyeem/
http://skipology.com/project/iphoneography-exhibition-hip-2b-square/