Tagged: adsense, breadcrumbs
-
AuthorPosts
-
February 4, 2021 at 12:57 am #1277489
Hi, Enfold Expert,
I want to display adsense after the breadcrumbs, i have this coding
function after_breadcrumb_func($breadcrumb){ $output = $breadcrumb; $output .= "<div>adsense here</div>"; return $output; } add_action('avia_breadcrumbs', 'after_breadcrumb_func');
This code is working fine & display ads but the code is placed in function.php file, but i want to put the adsense code directly in breadcrumb file: (/framework/php/class-breadcrumb.php) not in function.php file.
I don’t know, how to add the “<div>adsense code</div>” in breadcrumbs file (framework/php/class-breadcrumb.php) and which line number.
Thanks and hope someone will soon reply me.
- This topic was modified 3 years, 10 months ago by hamzakhankhan.
February 4, 2021 at 6:07 am #1277540Hi Hafeez Ullah,
The code can be found in enfold > framework > php > class-breadcrumb.php line 609-616.
However, using hooks is actually better since its basically the same as adding it on that page itself before the page is being rendered by the server.Best regards,
NikkoFebruary 4, 2021 at 9:21 pm #1277792@Niko
Could you kindly share the code, how to paste it there, should i directly put the <div>adsense code</div> or put above whole code, just shared the code with line number to past it directly. Thanks
February 5, 2021 at 6:35 am #1277852Hi Hafeez Ullah,
You can do it like this (however not advise this as you will be editing directly to the core):
$ad = "<div>adsense here</div>"; if ( $echo ) { echo $breadcrumb . $ad; } else { return $breadcrumb . $ad; }
Instead just use a hook just like this: (it’s basically the same thing as above)
add_filter('avia_breadcrumbs', function($breadcrumb) { $breadcrumb .= "<div>adsense here</div>"; return $breadcrumb; }, 10, 1);
Best regards,
Nikko- This reply was modified 3 years, 10 months ago by Nikko. Reason: wrong variable
February 8, 2021 at 10:28 pm #1278847hi, Niko
I have use my code in this way, and its working for me,
/* Close the breadcrumb trail containers. */ $breadcrumb .= '</div></div> <div class="ad" style="text-align: center;"><!-- CopyBloggerThemes_S2S_Leaderboard_ROS_Pos2 --><div id="bsa-zone_1611333824377"></div></div>';
However, i need to remove the div class on homepage, i have set frontpage, I want the div class “ad” should be appear everywhere except homepage of the site.
Please add condition to my code, so that the div >> ( <div class=”ad” style=”text-align: center;”><!– CopyBloggerThemes_S2S_Leaderboard_ROS_Pos2 –><div id=”bsa-zone_1611333824377″></div></div>’; ) should display everywhere on the blog except homepage.
to give you an idea, do something like this:
/* Close the breadcrumb trail containers. */ $breadcrumb .= '</div></div> echo if (!=homepage) display this div <div class="ad" style="text-align: center;"><!-- CopyBloggerThemes_S2S_Leaderboard_ROS_Pos2 --><div id="bsa-zone_1611333824377"></div></div>';
I hope you understand, thanks
- This reply was modified 3 years, 10 months ago by hamzakhankhan.
February 9, 2021 at 5:14 am #1278896Hi hamzakhankhan,
You can use the conditional tags for that: https://codex.wordpress.org/Conditional_Tags
I’ll just use the code I used above as an example:add_filter('avia_breadcrumbs', function($breadcrumb) { if ( !is_front_page() ) { $breadcrumb .= "<div>adsense here</div>"; } return $breadcrumb; }, 10, 1);
Hope this helps. :)
Best regards,
NikkoFebruary 9, 2021 at 10:32 pm #1279260Thanks its been resolved now!
February 10, 2021 at 2:23 am #1279286Hi hamzakhankhan,
We’re glad that we could help :)
Thanks for using Enfold and have a great day!Best regards,
Nikko -
AuthorPosts
- The topic ‘Adsense Code after Breadcrumbs Navigation’ is closed to new replies.