How to get the permanent link of featured image? (1 post)

  1. acjdesigns
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic