Need help with actions

I want to inject my ad script over here, but when I use this:

function dfp_ad_tag() { ?>

   My DFP Script

 <?php }

add_action( ‘x_before_the_content_begin’, ‘dfp_ad_tag’ );

The ad is placed just before the “NEW ON BLOG” section, not in the head section where I marked, I tried with different actions, but seems not working for me, can you help to find the right action, so that I can inject the script over there.

Thanks.

Hello Saswata,

Thanks for writing in! Please have your code enclosed with a container wrapper:

function dfp_ad_tag() { ?>
	<div class="x-container max width mtl">	
      My DFP Script
    </div>
<?php }
add_action( 'action_name', 'dfp_ad_tag' ); 

And then your action should be x_after_masthead_end if you are using a custom header. When you only have the default header, you will have to use x_after_view_renew__landmark-header.

We would love to know if this has worked for you. Thank you.

1 Like

Hi @ruenel thanks for your time,

As I use renew default header I use “x_after_view_renew__landmark-header” this action, but sadly it is not working in the front end.

Actually, I delete the landmark header from the posts and pages previously, is it the reason for not working?

REF URL: https://learnmechanical.com/plasma-arc-welding/

The function I use for injection is mentioned in the “Secure Note”.

Thanks.

Hi @ruenel sorry for chiming in again, I found an action “x_after_view_header_base” and it is working too.

I found this action, by searching in the forum, here is the thread: Hook Right After Header

Can you please confirm, should I use this, or there is any conflict?

Thanks Again.

Hey Saswata,

We could not say if it will conflict with anything in your project now or in the future. I could just say that action hooks will simply output what you attach to them.

If you use hooks even our theme’s hooks, you will need to understand how they work so you could say if using them is right for your project or not and you can say if will conflict with anything in your project.

Please note that we do not provide support for custom development even if you use our theme’s hooks because we’d be working on your customizations if we do that and we only offer that service for our Elite customers. If you want us to customize your site, you might want to subscribe to our Elite service here https://theme.co/elite

If subscribing to Elite is not an option, please consider upgrading to Pro and/or kindly wait for our Layout Builder which is coming soon.

Thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.