Feature Image Into Custom Post Type Template

Hi there,

I am running a custom post type template on my Child theme - VIEWS/RENEW/WP-SINGLE-Rooms.PHP

I am struggling to add the post type’s feature image to replace the following image url below:

<?php echo do_shortcode(' [cs_content] [cs_section bg_image="https://retreathome.co.za/wp-content/uploads/2017/09/Abberley_Hydrangea_006-1920x1272.jpg"

parallax=“false” separator_top_type=“none” separator_top_height=“50px” separator_top_angle_point=“50” separator_bottom_type=“none” separator_bottom_height=“50px” separator_bottom_angle_point=“50” style=“margin: 0px;padding: 45px 0px;”]
[cs_row inner_container=“true” marginless_columns=“false” style=“margin: 0px auto;padding: 0px;”][cs_column fade=“false” fade_animation=“in” fade_animation_offset=“45px” fade_duration=“750” type=“1/1” style=“padding: 0px;”][x_custom_headline level=“h1” looks_like=“h1” accent=“false” class=“cs-ta-center” style=“color: hsl(0, 0%, 100%);”]’.get_post_meta( get_the_ID() , ‘room_name’, true ).’[/x_custom_headline]
[/cs_column]
[/cs_row]
[/cs_section]
'); ?>

Please advise what I need to do.

Hi there,

Thanks for writing in.

You can change it to something like this

<?php 

$featured = wp_get_attachment_image_src( get_post_thumbnail_id() , 'full', true);

echo do_shortcode('

[cs_content]
[cs_section bg_image="'. $featured[0] .'" parallax="false" separator_top_type="none" separator_top_height="50px" separator_top_angle_point="50" separator_bottom_type="none" separator_bottom_height="50px" separator_bottom_angle_point="50" style="margin: 0px;padding: 45px 0px;"]
[cs_row inner_container="true" marginless_columns="false" style="margin: 0px auto;padding: 0px;"][cs_column fade="false" fade_animation="in" fade_animation_offset="45px" fade_duration="750" type="1/1" style="padding: 0px;"][x_custom_headline level="h1" looks_like="h1" accent="false" class="cs-ta-center" style="color: hsl(0, 0%, 100%);"]'.get_post_meta( get_the_ID() , 'room_name', true ).'[/x_custom_headline]
[/cs_column]
[/cs_row]
[/cs_section]
'); ?>

Hope this helps.

1 Like

Legend! I’ll try that

Let us know how it goes!

Is it possible to change the feature image for an acf single image - field: banner-image.

$bannerimage = wp_get_attachment_image_src(get_field('banner_image'), 'full', true);
 
 echo do_shortcode('	

	
       [cs_content][cs_section bg_image="'. $bannerimage[0] .'"

Currently this method isn’t showing anything. Please advise.

Hi There,

Would you mind providing us with login credentials(by clicking on the Secure Note button at the bottom) so we can take a closer look? To do this, you can make a post with the following info:

  • Link login to your site
  • WordPress Admin username / password

Thanks.