Some users might want to change the div container Advanced Ads uses for ad placeholders in Advanced Ads Pro cache-busting or when some output options like a margin are selected.

The code below changes the div into an article container.

Please notice that this could break some other part in Advanced Ads, especially JavaScript-based ad placements. Changing the container element is not officially supported.

/**
 * Change <div> container for ads to <article>
 * Does not work with cache-busting containers
 *
 * @param string $output ad output.
 * @param object $ad Advanced_Ads_Ad object.
 *
 * @return string
 */
function advads_change_wrapper_div( $output, $ad ) {
	$output = preg_replace( '/^(<div )/', '<article ', $output );
	$output = preg_replace( '/(<\/div>)$/', '</article>', $output );

	return $output;
}
add_filter( 'advanced-ads-ad-output', 'advads_change_wrapper_div', 10, 2 );

/**
 * Change <div> container for cache-busting ads to <article>
 *
 * @param string $output ad output.
 * @param object $ad Advanced_Ads_Ad object.
 * @param array  $args additional arguments.
 *
 * @return string
 */
function advads_change_passive_wrapper_div( $output, $ad, $args ) {
	$output = preg_replace( '/^(<div )/', '<article ', $output );
	$output = preg_replace( '/(<\/div>)$/', '</article>', $output );

	return $output;
}
add_filter( 'advanced-ads-ad-select-override-by-ad', 'advads_change_passive_wrapper_div', 20, 3 );

A user of Advanced Ads shares his implementation of the above code limiting it by single ads (instead of ads and groups).

See this gist.

 Code-Snippets