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

Comments

  • Hi,

    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!
  • Thank you for your answer.
    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.
  • No, we can not agree with you unfortunately that this is a bug. You must did something wrong in the code because this function works as supposed to work
Sign In or Register to comment.