Please note that we provide the code snippets and content on this page are without any guarantee or support. In most cases, these pages are created on requests or based on individual solutions sent to us by other users. After it was published, we are only reviewing the code and content when we are made aware of an issue. Please let us know if you find one.

Please only use the codes if you understand them and know how to add custom code to your WordPress site.

The Custom Code option that comes with Advanced Ads Pro allows you to deliver additional codes with your ads. While initially meant to deliver tracking codes, it can be used to display something as well. The option is delivered after the ad content by default. You can use the code below to a) deliver the custom code above the ad code as well and b) disable the output below the ad code.

Use the following code in your functions.php or a custom plugin.

add_action( 'advanced-ads-output-final', 'my_advanced_ads_pro_custom_code_above_ad', 10, 2 ); function my_advanced_ads_pro_custom_code_above_ad( $output, $ad ){ return $ad->output["custom-code"] . $output; }
Code language: PHP (php)

When using your custom code above the ad then you might want to prevent the default output below it. To do that, also add the following code to your functions.php

add_filter( 'advanced_ads_pro_output_custom_code', 'my_advanced_ads_pro_custom_code_prevent_default_output', 10, 2 ); function my_advanced_ads_pro_custom_code_prevent_default_output( $custom_code, $ad ){ return ''; }
Code language: PHP (php)

You can also use the code above to manipulate the Custom Code output dynamically, e.g., based on the individual ad.