Support » Fixing WordPress » How to get the permanent link of featured image?

  • I’m wondering what is the PHP code to get the permanent link of a featured image in a post. I can’t use just the image link because each post has a different featured image. Any help is highly appreciated!

    Currently I’m trying:

    function get_url(){
    	$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), array($featured_image_width,$featured_image_height));
    	wp_localize_script('post-tiles', 'get_url', $url);
    add_action('wp_enqueue_scripts', 'get_url');

    For some reason, the image is showing up as “null” on the page. Did I have to do something extra to load the $url variable as one that can be used in the javascript? Some examples have arrays, but I don’t know why I would use an array when I have only to pass the variable.

  • The topic ‘How to get the permanent link of featured image?’ is closed to new replies.