• Resolved windofchange87

    (@windofchange87)


    Hi everyone, I would like to change the header image within the pages and categories in the div “newsmag-custom-header” instead of the default image.
    How can I customize the image for each one?

    esempio

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @windofchange87,

    You can change the header image for each page. Just edit a page and add it a featured image.
    As for the categories, take a look here: https://github.com/MachoThemes/newsmag-lite/blob/master/archive.php#L18
    This is where the default image is added. You will need to check if it’s the category page because that template is used for multiple pages.
    After that, get the category image and display it.

    Best regards,
    Mihaela

    Thread Starter windofchange87

    (@windofchange87)

    Thank you for the reply,
    I opted for this solution I do not know if right, but at least it works

    
    $current_category = single_cat_title("", false);
    $current_category = strtolower($current_category);
    $current_category = str_replace(" ", "-", $current_category);
    if ( is_category( '8' ) ){
    	$current_category = str_replace("società", "societa", $current_category);
    }
    $current_category = get_template_directory_uri() . "/assets/images/" . $current_category . ".png"; 
    
    if ( ! empty( $current_category ) ): ?>
    	<?php 
    		$additional = 'style="background-image:url(' . esc_url( $current_category ) . '"' 
    	?>
    <?php endif; ?>
    
    	<div class="newsmag-custom-header" <?php echo $additional ?>>
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘modify header image’ is closed to new replies.