Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

WordPress: Get featured image url of home page in another page

I have two pages created Home and About page.

I have set a featured image in my home page.

I want to get the image url of whatever featured image is set in my home page and display it on my about page (dynamic).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I am using my own custom template.

If possible I want to achieve it this way:

<img src="<?php get_homepage_featured_image_url(); //Something like this in wordpress. ?>"

>Solution :

You have to use get_option to find the home page.

$home_id = get_option('page_on_front');
$home_thumb_id = get_post_thumbnail_id($home_id);

echo wp_get_attachment_image($home_thumb_id, 'large');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading