Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #882879

    Have been trying to move from the Visual Composer editor to AVIA and notice problem using shortcodes with Enfold.
    I have Google Adsense throughout my website which works if I use the standard Adsense code, but it goes crazy if I put that code into a short code in the functions.php file using the AVIA editor although it works perfect using Visual Composer.
    With Enfold having the code served by a short code makes it leave it’s container and jump above the content.

    Example of what it should look like https://www.bigboytravel.com/contact-test/
    What it looks like using a short code https://www.bigboytravel.com/contact-test-3/

    In addition to pushing the shortcode item to the top of the content t also breaks the page everything I click update on the page and requires a page refresh.

    Why do I want to use short codes instead of the regular code?
    Because if I have different short codes throughout the website I can just change what that short code does in one spot in the functions.php file and every spot on all my pages on the website using that short code is updated at once. This is super important to change ads code out without editing 200 pages. This is especially important if I want to switch between Adsense Code and a JPEG ad on a section on entire my site in a couple clicks.

    Here is my code I’m using to make my short code of [wp_ad_camp_5]

    function medium_m_shortcode() {
    ?>
       <center><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
       <!-- 336x280 Content -->
       <ins class="adsbygoogle"
           style="display: block; float: center; width: 336px; height: 280px;"
           data-ad-client="ca-pub-xxxxxxxxxxxxxxxxx"
           data-ad-slot="xxxxxxxxxx"></ins>
       <script>
       (adsbygoogle = window.adsbygoogle || []).push({});
       </script></center>
    <?php
    }
    add_shortcode('wp_ad_camp_5', 'medium_m_shortcode');

    Jon

    #883147

    Hey Jon,

    The look the same on my side, can you please post a few screenshots of the issue on your side?

    Best regards,
    Victoria

    #883182

    Victoria,
    Here you go
    Correct placement using the standard Adsense code

    Error using the same code inside a short code, pushed it above the content.
    Doesn’t matter how far down the page it is or if it is inside either a Code element or Text element, still pushes above the content.
    This does not happen inside sidebar widgets or in content using Visual Composer as the editor, only happens when I’m using the standard Enfold AVIA editor.

    Thanks again for your help,
    Jon

    #884526

    Hi,

    Thank you for the info. If you don’t mind, we would like to access the site so that we can see what’s going on in the editor. Please provide the login details in the private field.

    Best regards,
    Ismael

    #884545

    here you go

    #885049

    Hi,

    The shortcodes or elements after the “wp_ad_camp_5” in the “contact-test-3” are broken. Please try to recreate the page from scratch. Add the adsense script instead of the shortcode.

    Best regards,
    Ismael

    #885198

    Ismael,

    Thank you for your response.
    Is it safe to assume that it is the AVIA editor that is breaking the short codes?

    I set them up in the functions.php file and they are working perfect in both the side bar widgets and page on the site using the Visual Composer editor. Seems to only be an issue when using the AVIA editor, which is what I would like to do on all pages so I can get ride of Visual Composer.
    Originally I had to build the site with the 3rd part editor because Enfold didn’t have screen size based visibility options, but now it does.

    I can revert back to using the raw script but creates an issue because I have 250 pages and want the ability to change the contents of a short code to a stand alone ad or JPG ad if needed site wide instead of changing all 250 pages one by one.

    Jon

    #885432

    Hi,

    The adsense shortcode doesn’t break the theme’s shortcode in a test page but the adsense is rendering outside the column container. I’m not sure why.

    Best regards,
    Ismael

    #885874

    I’m not sure either, which is why I asked
    It doesn’t act like this inside the sidebar/footer widgets or when using the Visual Composer editors, it’s only an issue with the AVIA editor
    The 250 other pages on my site which aren’t using AVIA are working correctly using shortcodes to serve Adsense.

    Jon.

    #886917

    Hi,

    Did you remove the user account? We would like to test it again.

    Best regards,
    Ismael

    #887134

    sorry I switched from to better hosting and it reset my passwords

    #887689

    Hi,

    Thank you for the info.

    We had to create a temporary placeholder for the adsense and then append it the actual container via jQuery. ( see private field )

    function medium_m_shortcode() {
    ?>
       <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
       <!-- 336x280 Content -->+
    <div class="adsenseplaceholder">
    
       <ins class="adsbygoogle"
           style="display: block; float: center; width: 336px; height: 280px;"
           data-ad-client="ca-pub-3788205869703165"
           data-ad-slot="6252843244"></ins></div>
    <script>
       (adsbygoogle = window.adsbygoogle || []).push({});
       </script>
    
    <?php
    }
    add_shortcode('wp_ad_camp_5', 'medium_m_shortcode');
    
    // custom script
    add_action( 'wp_footer', 'ava_custom_script' );
    function ava_custom_script() {
    ?>
    <script type="text/javascript">
    (function($) {
    	$(document).ready(function(){
    	    $(".adsenseplaceholder").find("iframe").appendTo(".adsensediv center");+
    			$(".adsensediv").css({'width' : '100%', 'height' : '280px'});
    	    $(".adsenseplaceholder").remove();
    	});
    })(jQuery);
    </script>
    <?php
    }
    

    The adsense script is wrap inside the “adsenseplaceholder” container and then the script will append it to the “adsensdiv” container which is inside the codeblock element.

    Best regards,
    Ismael

    #888042

    Ismael,

    Thanks for your help.

    That method didn’t seem to work as it still broke the container and moved it above the content, but turned the ad into a + sign.
    I will copy the site to a staging area later today and supply you with new log ins and sFTP for the staging.

    Jon

    #888325

    Hi,

    Did you check the post above? It’s working there.

    Best regards,
    Ismael

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.