Scripts on Excluded pages

Marko Krstić
25 Apr 2021

At the moment we have option to select pages on which you want to apply scripts.

Thats why I made a small code snippet to help you create this option as well.

Write Page, Post ID or Slug on witch pages you don’t want that script is applied and it will be applied on all the rest.

In this example bellow I don’t want red background on Page ID 5 ( homepage ) and “Page 3” as well.

<?php if (is_page( array( 5, 'page-3' ) ) ) : ?>
    <!-- Do nothing -->
<?php else : ?>
    <!-- Insert your code here -->
	<style>
	  body{
		background: red;
	  }
	</style>  
<?php endif; ?>

Trigger Location: Conditions
Script Location: PHP

screenshot 2021 04 25 at 13.11.05

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy