Skip to content

Instantly share code, notes, and snippets.

@ambercouch
Last active May 22, 2019 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambercouch/825af92d4312769318c2e987771b64d1 to your computer and use it in GitHub Desktop.
Save ambercouch/825af92d4312769318c2e987771b64d1 to your computer and use it in GitHub Desktop.
Wordpress widget logic contidional code to use in widgets
<?php
//Paste the code below into the widget logic field of you widget and edit the page IDs as needed
//The code below will display your widget on pages 8,9 and 10 and any page that is a child of page 8
global $post; return (is_page(array(8,9,10)) || in_array($post->post_parent, array(8)));
//The code below will display you widget on pages that us the faq-page.php template file
global $post; return (get_page_template_slug( $post->ID ) == 'page-templates/faq-page.php');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment