-
Notifications
You must be signed in to change notification settings - Fork 39
Add Google ad banner above logo in rtPanel
In previous post, we have seen the rtPanel Hooks map. Now lets see how we can we use 'rtPanel Hooks' to add extra functionality while developing theme.
At first we will create a custom field (textarea) in the custom theme option. So that when google ads script is added to that field, the google ads will appear before logo of the site. The custom field can be defined in the file 'rtp-custom-theme-options.php' which is under the lib folder of Child theme of rtPanel. (learn more about - custom theme options in rtPanel)
Once textarea field is created, we will add the google ads script to this textarea. Now first we will create custom function as "rtp_google_ads" in the 'function.php' which is present in the child theme folder. This is to display the google-ads.
function rtp_google_ads(){
global $rtp_custom_theme_options;
echo $rtp_custom_theme_options['google_ads'];
}
So once function is created, we need to “hook” the function to the 'rtp_hook_before_logo' action hook so that Google ad will be displayed before the logo. So the code will be as below:
add_action('rtp_hook_before_logo','rtp_google_ads');
After adding this code the google ads will be displayed before the logo. It is show in below screenshot.
Once google ad is displayed we will add style it according. This can be done by adding CSS styling to the 'style.php' file in the child theme folder.
Isn't it pretty easy to add our own functionality to the theme!!! :)
This is just a small example to demonstrate how our 'rtp_hook_before_logo' can be used. But there are many more things that can be achieved using this hook, as long as your creativity will not end. Some example usages are adding social networking icons, adding images, adding search textbox etc.
Do let us know, your creative usages of rtPanel Hooks via comments.
rtPanel:
- End-User Documentation
- Developer Documentation
- General
- Customizing Image Sliders in rtPanel Child Theme
- Add Google ad-banner above logo in rtPanel
- Customize rtPanel Footer Information
- Filters in rtPanel
- Integrated SEO plugin in rtPanel
- Create Metabox on rtPanel Child Theme
- Add Google Adsense Link Unit In Header
- Create Custom Taxonomy on rtPanel
- rtPanel:Comments with Gravatar
- rtPanel: Subscribe Widget
- Create Custom Post Type with rtPanel Child Theme
- rtPanel Theme Options ‘General’
- Using rtp_generate_thumbs() function in child theme
- WordPress Debugger 'WP_DEBUG'
- Adding Social Sharing Button to Website: Using Text Widget
- Clickable header in rtPanel child theme
- CSS Checklist for developers
- Implementing rtp-slider in the child theme
- Creating custom page templates in rtPanel child theme
- Child Theme development using rtPanel – Part I
- Child Theme development using rtPanel – Part 2
- rtPanel Developer Program: Standards Guidelines
- rtPanel Developer Program:Test Project
- Removing the default rtPanel Hooks
- Browser Specific Styling