0

I have set the add_theme_support('custom-header', $defaults); in the functions.php file. It shows up in the customiser but when I add an image it does not appear in the preview or the live site.

My code is:

$defaults = array(

'height'                 => 250,
'header-text'            => true,
'uploads'                => true,
'video'                  => true
);
add_theme_support( 'custom-header', $defaults );

The height of 250 does show up as a space is etched out for the image to be added but the image itself won't appear when uploaded. Also the cropping of the image doesn't work, it just displays a dark image, I hit crop and it saves as is, could that be the issue? It's not saving right?

The same thing happens for a video, it shows up in the customiser to add the video but it does not appear in the preview or the site.

  • add_theme_support() is only step one. You still need to actually output it into your template: developer.wordpress.org/themes/functionality/custom-headers/… – Jacob Peattie Jun 22 '19 at 9:46
  • Ok I've added the get_header_image() code that is in that link along with adding a height argument to the add_theme_support() $defaults variable. The cropping is now working but it's still not showing up on the site. – Niall Jun 22 '19 at 10:04
  • Got it working. The code need to be within the <header> tags rather than simply a div with an id of site-header. Thanks for your help! – Niall Jun 22 '19 at 10:11
  • Add your solution as answer, you can accept your own answer. Or you might consider deleting your question. Thanks. – Nicolai Jun 22 '19 at 12:38
  • Ah ok. Will create a comment, thanks. – Niall Jun 23 '19 at 13:09
0

Got it working. I had to call the function in my page where I want it to work, the method of doing so is here: https://developer.wordpress.org/themes/functionality/custom-headers/#displaying-custom-header (link provided by Jacob Peattie) and it needs to be within the tags rather than simply a div with an id of site-header.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.