Adding subheader image to my own page template
Hello,
I have successfully written a function to display a specific subheader image in header.php depending on the content type. On my CPT it works but on normal pages, it doesn't.
I need to display the image uploaded in the "subheader image" field in the page editor. Currently, it's displaying the page's featured image.
Which function should I use to return the subheader image URL?
thank you
I have successfully written a function to display a specific subheader image in header.php depending on the content type. On my CPT it works but on normal pages, it doesn't.
I need to display the image uploaded in the "subheader image" field in the page editor. Currently, it's displaying the page's featured image.
Which function should I use to return the subheader image URL?
thank you
Comments
this requires files customization what in reference to Item Support Policy is not allowed. So if you want to modify files and don't know how, you should contact with your web developer.
P.S. For subheader image url is responsible mfn_opts_get( 'img-subheader-bg' )
Thanks for understanding!
I ultimately made it work but without using the theme's functions. I looked the field's key in the database and used the get_post_meta function as follows:
$header_style .= ' style="background-image:url('. esc_url( get_post_meta( get_the_ID(), 'mfn-post-subheader-image', true ) ) .');"';
It could be a bug by the way, when I used get_post_meta( mfn_ID(), 'mfn-post-header-bg', true ) it didn't return anything.