I am using the <?php the_shortlink(); ?> code and I want to display just the link and not the default text. For example, it will say something like "Blog Post Shortlink" and below it, it will display the shortlink "example.com/?=whatever". How can I do this? Thank you!
Try
<?php
global $post;
wp_get_shortlink( $post->ID );
?>
I tried using that code and it does not work. I doesn't show anything.
I changed it to the_shortlink and it now shows the post ID, however I would like for it to show the whole link (including example.com?=" or whatever it shows. Thanks!
It worked! All I did was copied this code <?php echo wp_get_shortlink(get_the_ID()); ?> and it shows up nicely. Thank you!
This code also seems to work if you get rid of get_theID() from inside the parentheses.
stevec828
Member
Posted 7 months ago #
Thanks for this guys. I wanted to create a custom RSS feed with the shortlink instead of permalink, used <?php echo wp_get_shortlink(get_the_ID()); ?>, and it worked like a charm.