I want users to be able to set a default image for a category, and have it appear in the header for the category page. So, for example, here:
http://www.radiofreepalmer.org/category/programs/techtalk/
The gray header area currently shows the category description. I've installed the following plugin:
http://www.radiofreepalmer.org/category/programs/techtalk/
https://wordpress.org/plugins/hmk-add-images-for-categories-and-pages/installation/
That lets me set a default image for a category, and I've done so. Now, in theory, the image can be displayed to the front-end by using a shortcode ['header_ads_image'] or using <?php if (function_exists('hmk_taxonomy_image_url')) echo hmk_taxonomy_image_url(); ?> to get the url and put it in any img tag in header or any page template.
I obviously can't do that using CSS, and I'm not sure that, in this theme, I could easily set the class .source-page (the class of the header area) to have a background image that's set via php.
Am I going about this the wrong way? Any recommendations? Thank you!
timDesain Nanang answers:
Hi Sir, have you tried this:
add_action('wp_head', 'wpq_wp_head');
function wpq_wp_head(){
if (function_exists('hmk_taxonomy_image_url')) {
$hmk_image = esc_url( hmk_taxonomy_image_url() );
if(!empty( $hmk_image ) ){
?><style type="text/css"><?php
echo ".source-page {background: #FAC564 url('".hmk_taxonomy_image_url()."') repeat top !important;} ";
?></style><?php
}
}
}
put the code on theme's functions.php
michaelmiller comments:
I did that, and it worked perfectly. Thank you, sir!
timDesain Nanang comments:
You are welcome.