php – Need to add a post’s featured image to a section on the frontpage


It looks like I will need to create custom PHP code for this and either add it to my includes directory within a custom PHP file, or to the functions.php file.

I need the ability to use a featured image in a post and be able to also dynamically display that same image in a gallery on the frontpage.

I am not a PHP master by any means, but I know a bit to get around.

My guess is I would need something comparable to this:

if ( has_post_thumbnail() ) {     
    echo '<div style="background-image: url(" . get_the_post_thumbnail_url() . ');></div>';

How would I get the featured image to display within in a certain section on the frontpage?
Would I need to create a custom class to place this in a specific section on the frontpage?

There’s a “Projects” custom post type where the actual posts are created. There are fields within this post type created using ACF. There’s a “Project Featured” section in this custom post type that offers a toggle to turn off or on “Featured”. If the toggle is on, that is when the featured image should be used and displayed on the frontpage.


Ron TheWebDev 5 months 2022-05-11T15:18:46-05:00 0 Answers 0 views 0

Leave an answer