Support » Plugins » Get Permalink

  • Resolved jennifer2010


    Hi Everyone 🙂

    I’m using the following code placed in my functions.php file in order to grab the permalink for usage with a shortcode. The problem is it requires me to specify a post ID for it to work, instead of just grabbing the permalink automatically. [permalink id=49]

    How can I edit the code so that it returns the permalink automatically without having to manually add the ID every time?

    Thank you so much!

    function permalink_thingy($atts) {
    ‘id’ => 1,
    ‘text’ => “” // default value if none supplied
    ), $atts));

    if ($text) {
    $url = get_permalink($id);
    return “$text“;
    } else {
    return get_permalink($id);
    add_shortcode(‘permalink’, ‘permalink_thingy’);

Viewing 1 replies (of 1 total)
  • Resolved:

    function get_url() {
    return get_permalink($post->ID);
    add_shortcode(‘GetURL’, ‘get_url’);

    Shortcode is [GetURL]

Viewing 1 replies (of 1 total)
  • The topic ‘Get Permalink’ is closed to new replies.