You can easily integrate your theme or plugin with Epic Advertisement. In this section, we will explain how to create a custom ad placement.
You can follow the instruction below:
- Firstly you need to register the custom ad placement. If you’re using a theme, you can put them on the `functions.php` file or if you’re using a plugin you can put them on the root file of the plugin. You can check the code structure below:
add_filter( 'epic_ad_register_placement', function( $value ) {
$value[] = [
'id' => 'epic',
'name' => __('Epic'),
'description' => __('Custom Epic Ads Location'),
];
return $value;
} );
On the code above, you can adjust the id value, name value and description value as you need.
- Then you need to create a filter hook to add the ad location item. Please note, you need to name the filter with this structure `epic_ad_location_IDPlacement`.
At this time, we use `epic` as id placement based on the example code above. You can check the example below:
add_filter( 'epic_ad_location_epic', function( $value ) {
$value[] = [
'location' => 'top_header',
'title' => __('Top Header'),
'thumbnail' => 'top-header.png',
];
return $value;
} );
On the code above, you need to set the title value, thumbnail value and location value. For the thumbnail file, you can put the file on the root folder of your theme or plugin.
- After that, you need to create an action hook for rendering the ads element on the frontend. You need to put the code where the ads need to be shown.
This is the action hook structure “`do_action( ‘epic_ad_render_IDPlacement_Location’ );`”. For example, you can use this code below:
do_action( 'epic_ad_render_jblog_top_header' );
- You can put the code above everywhere you want. For example, you can put them on the `header.php`.