• Resolved Rafa?

    (@ayek)


    Hi Advanced Ads Support!

    How to alter the outer ad container tag from DIV to ASIDE?

    I need this especially when an ad is injected into the post content.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support schmidt25

    (@schmidt25)

    Hi Rafa?,

    We provide information about how to change the div container to other HTML elements in our custom code section. You can find it here.

    Best regards and a wonderful Sunday,
    Joachim

    Thread Starter Rafa?

    (@ayek)

    Thank you, Joachim!
    It would be great if I may alter the tag only on content placements (after nth paragraph). How to filter only them?

    Plugin Support schmidt25

    (@schmidt25)

    Hi,

    Yes, that would be possible.

    The second parameter in this filter is the Advanced_Ads_Ad class, which can call the options() method which returns an array. If available and inside a placement, the key placement_type contains the type of the placement.

    As a starting point, you might test something like:
    $options = $ad->options(); if (isset($options['placement_type']) && $options['placement_type'] === 'post_top') {

    Please keep in mind that we provide the code snippets and content on this page 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 only use the codes if you understand them and know how to add custom code to your WordPress site.

    Best regards,
    Joachim

    Thread Starter Rafa?

    (@ayek)

    Thank you!

    I’ve changed the type to 'post_content'. Works!

    function advads_change_wrapper_div( $output, $ad ) {
      $options = $ad->options();
      if (isset($options['placement_type']) 
      && $options['placement_type'] === 'post_content') 
      {
        $output = preg_replace( '/^(<div )/', '<aside ', $output );
        $output = preg_replace( '/(<\/div>)$/', '</aside>', $output );
      }
      return $output;
    }
    add_filter( 'advanced-ads-ad-output', 'advads_change_wrapper_div', 10, 2 );

    To be honest, I’d prefer to change the most outer tag of the AdvAds insert. Now it happens on container with [class$="target"].

    Thread Starter Rafa?

    (@ayek)

    I’ve figured out a workaround earlier.
    Used Insert after nth paragraph
    My $ad_code = <aside class="advads-content">[the_ad_placement id="the-name-of-my-manual-placement"]</aside>
    where i put the shortcode of my Manual Placement.

    Do you think this solution is safe / has any weaknesses?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change DIV to ASIDE tag’ is closed to new replies.