Banner ad doesnt work 728x90


#1

Hello there, I need help please,
is it possible to put google ad to that banner ad space? I think so right?
I tried to put the code where it says “Header ad link” but nothing happens, I just don’t want to insert a banner and put the link, I want to know if google or similar adds work on that space?


#2

Hello there,

It only accepts banner image by default. To use custom code ads, you’d need to use a child theme’s functions and add this code:

function greatmag_site_branding() {
	$header_ad_image 	= get_theme_mod('header_ad_image');
	$header_ad_url		= get_theme_mod('header_ad_url');
	?>
		<div class="site-branding vhome3 row m0">
			<div class="container">
				<div class="main-logo">
					<div class="media">
						<?php if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) : ?>
						<div class="media-left">
							<?php the_custom_logo(); ?>
						</div>
						<?php endif; ?>
						<div class="media-body">
							<?php
							$description = get_bloginfo( 'description', 'display' );
							if ( $description || is_customize_preview() ) : ?>
								<p class="site-description site-slogan"><?php echo $description; /* WPCS: xss ok. */ ?></p>
							<?php
							endif;
							if ( is_front_page() && is_home() ) : ?>
								<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
							<?php else : ?>
								<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
							<?php
							endif;
							?>
						</div>
					</div>
				</div>
				<?php if ( $header_ad_image ) : ?>
					<div class="header-ad">
						<a target="_blank" href="<?php echo esc_url($header_ad_url); ?>"><img src="<?php echo esc_url($header_ad_image); ?>"/></a>
					</div>
				<?php endif; ?>
			</div>
		</div><!-- .site-branding -->
	<?php
}

Replace this code block:

<?php if ( $header_ad_image ) : ?>
	<div class="header-ad">
		<a target="_blank" href="<?php echo esc_url($header_ad_url); ?>"><img src="<?php echo esc_url($header_ad_image); ?>"/></a>
	</div>
<?php endif; ?>

with:

<?php if ( $header_ad_image ) : ?>
	<div class="header-ad">
    <!-- Your ads code goes here -->
  </div>
<?php endif; ?>

Regards,
Kharis


#3

Hey thanks for the reply appreciate it, but it still doesn’t work I have tried the way you mentioned here but still no luck. what am i doing wrong?
this is the code I pasted there.

<?php if ( $header_ad_image ) : ?>
<div class="header-ad">
<script type="text/javascript">

( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { ‘units’ : [] }; };
var unit = {“calltype”:“async[2]”,“publisher”:“gethindichords”,“width”:728,“height”:90,“sid”:“Chitika Default”};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write(’

’);
}());
<?php endif; ?>

#4

Try removing <?php if ( $header_ad_image ) : ?> at the most top and <?php endif; ?> at the most bottom line.

Regards,
Kharis


#5

You are the best, that works just fine, thanks for the help @kharisblank
Regards,
Nad


#6

You’re welcome Nad!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis