Widget logic use just conditions. Don’t add additional PHP
If you want to create php code, put either to a code snippet of functions.php of the child theme.
Thanks for replying but can you explain why this is shown as an example on the plugin page: https://ww.wp.xz.cn/plugins/widget-logic/
… however if you are correct how would I do this
I want Widget Logic to make the widget appear on all the children of a page
What code should I put in functions.php and what code to put in Widget Logic?
Thank you in advance
I have always put for widget logic only a condition without if statement, commonly a function
some_function()
but of course you can use more complex conditions like
(some_function() || some_other-function())
If you put the function, the function just should return true or false on the base, where it has been called. I have been used this kind of system for setting parent page and sub-pages inside my own function
$currentUrl='https://' . $_SERVER['HTTP_HOST']. $_SERVER['REQUEST_URI'];
$somevariable=stristr($currentUrl,'/some-page-name/');
Well, I am afraid to say that
global $post; return (is_page('7651') || ($post->post_parent=="7651"));
does work
It puts the widget on page 7651 and all its immediate children
The reason I could not get it to work was because the pages used the full-width template and did not allow for any widgets
Mea culpa
I didn’t know that I could put other PHP as a condition. $post->post_parent would be usefull also for me.
I tried to replace
$blogi=stristr($currentUrl,’/’.SITEROOT.’/blogikirjoitukset’);
with
$blogi = (is_page(‘173’) || ($post->post_parent==”173″));
but that didn’t work.