This is related to my old ticket: https://toolset.com/forums/topic/featured-image-as-background/ but I have tried to add all the information here.
Hi 🙂
There's the problem that I'm not able to make anything on this page full width, the single-psykologhus.php and content-psykologhus.php should be correct. I know I could just remove the CSS that sets the standard content width, but I only need some things to be full width, not all content.
Also, I am trying to create a banner for a post type called "Psykologhuse", and need to display the posts featured image as a background image for a div.
I've been able to make it work correctly in a view of psycologists, so the code works, I'm doing something wrong.
I have it displaying a background image on the post type for "Psykologhuse", but it's not showing the correct featured image.
The posts in "Psykologhuse"
hidden link
hidden link
hidden link
This is the original code that I put in toolset custom code section:
// Add Shortcode
function get_featured_url($atts) {
// Attributes
$vals=shortcode_atts(
array(
'post_id' => '',
), $atts );
$feat_image = wp_get_attachment_url( get_post_thumbnail_id($vals["post_id"]) );
return "style = 'background-image: url(". esc_url($feat_image).");'";
}
add_shortcode( 'get_featured_url', 'get_featured_url' );
I can't get it to work if I insert the code in the content template, so I inserted the following code in a view:
<div class="cover" [get_featured_url post_id="[wpv-post-id id='$psykologhus']"]>
<h1>[types field='psykologhus-banner-overskrift' item='$current_page'][/types]</h1>
<br/>
<a class="findpsykolog" href="#findpsykolog">Find psykolog</a>
</div>
I then inserted the view into the content template for "Psykologhuse":
{!{wpv-view name='psykologhus-banner' limit='1'}!}
But it's a mess, maybe I need to clean up the structure, I have a lot of post relationships, hope you can help.
VIEW ID 13930 "Psykologhus banner"
CONTENT TEMPLATE ID 13733 "Psykologhus"
Thanks
Lykke