Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hello,

    It is possible, but it depends how your snippet is written. Do you have an example you could share with me?

    Thread Starter grimbuehler

    (@grimbuehler)

    Hi Shea,
    the script is

    function elementor_accordion_title() { 
    	if ( is_page( array( 309, 378, 398, 817 ) ) ) { ?>
    	<script>
    		jQuery(document).ready(function() {
    			jQuery( '.elementor-accordion .elementor-tab-title' ).removeClass( 'elementor-active' );
    			jQuery( '.elementor-accordion .elementor-tab-content' ).css( 'display', 'none' );
    		});
    	</script>
    <?php }
    }
    add_action( 'wp_footer', 'elementor_accordion_title', 99 );

    I found a solution like that (the opposite I’ve asked for: show only on certain pages):

    function elementor_accordion_title() { 
    	if ( is_page( array( 309, 378, 398, 817 ) ) ) { ?>
    	<script>
    		jQuery(document).ready(function() {
    			jQuery( '.elementor-accordion .elementor-tab-title' ).removeClass( 'elementor-active' );
    			jQuery( '.elementor-accordion .elementor-tab-content' ).css( 'display', 'none' );
    		});
    	</script>
    <?php }
    }
    add_action( 'wp_footer', 'elementor_accordion_title', 99 );

    This works for me. But from Drupal I know a similar module where I had a option to ?exclude on? or ?show only on? as you have it like ?on Frontend? or ?everywhere?…

    Thank you for your reply.

    • This reply was modified 5 years, 10 months ago by grimbuehler.
    Plugin Author Shea Bunge

    (@bungeshea)

    There isn’t a UI method for doing this sort of thing. WordPress provides a number of different template tags for a variety of situations, and I feel that it’s easier and more powerful to let people make use of those template tags in their snippets instead of trying to make settings fields for each one.

    In response to your question, you can make your snippet not run on certain pages by adding a not operator (!) before the check. Here’s an example:

    add_action( 'wp_footer', function () { 
    	if ( ! is_page( array( 309, 378, 398, 817 ) ) ) { ?>
    	<script>
    		jQuery(document).ready(function() {
    			jQuery( '.elementor-accordion .elementor-tab-title' ).removeClass( 'elementor-active' );
    			jQuery( '.elementor-accordion .elementor-tab-content' ).css( 'display', 'none' );
    		});
    	</script>
    <?php }
    }, 99 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude snippet on certain pages’ is closed to new replies.