• Resolved vishnua

    (@vishnua)


    Need to hide / Disable some of the div used in by theme.
    is there any option to add a class to the specific div’s so that it will disable in the AMP version only?

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Milind More

    (@milindmore22)

    Hello @vishnua

    If you are able to edit theme code I will recommend using the amp_is_request() function.

    example :

    
    // If it's not AMP page display the div.
    if ( function_exists( 'amp_is_request' ) && ! amp_is_request() ) {
         ?>
            <div class="show-on-normal-site">Display this div only on non-AMP page.</div>
         <?php
    }
    

    if you are non-dev you can also hide a div using CSS specification html[amp]

    eg:

    
    html[amp] .hide-this-div-on-amp {
       display:none;
    }
    

    Hope this helps!

    Plugin Author Weston Ruter

    (@westonruter)

    The logic condition may make more sense as: ! function_exists( 'amp_is_request' ) || ! amp_is_request() so that the non-AMP code is served when the AMP plugin is deactivated.

    Thread Starter vishnua

    (@vishnua)

    Thanks, @milindmore22 and @westonruter have tried amp_is_request function but it breaks theme, so have switched to CSS div option and it worked.

    have a class
    <div class="top_scroll row>
    which is needed to hide can you give the full code with amp_is_request()

    Plugin Support Milind More

    (@milindmore22)

    Hello @vishnua

    Please try the following code.

    
    if ( ! function_exists( 'amp_is_request' ) || ( function_exists( 'amp_is_request' ) && ! amp_is_request() ) ) {
    	?>
    	<div class="top_scroll row>
               <!-- Your content here -->
    	</div>	 
    	<?php
    }

    In meantime, I will work on a mini plugin that might help you remove element with the class

    Plugin Support Milind More

    (@milindmore22)

    Hello @vishnua

    Please download and install this mini plugin, once you install it use noamphtml class anywhere to hide any element

    eg:

    
    <div class="top_scroll row noamphtml">
               <!-- Your content here -->
    </div>
    

    OR

    You can use the mini plugin’s filter to add your own classes

    eg: add the code below in your themes functions.php or in a custom plugin (the code will only work with mini plugin)

    add_filter(
    	'amp_hide_classes',
    	function( $classes ) {
    		$classes[] = 'top_scroll';
    		return $classes;
    	}
    );
    

    Hope this helps!

    @vishnua As we haven’t received a response, I’ll mark this as resolved. Feel free to open a new support topic if you continue to encounter issues, or reopen this topic and we’d be happy to assist. Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Hide some DIV’ is closed to new replies.