Problems with actions and filters
-
I’m having some problems with the
wp_head
hook and thethe_content
filter in a plugin I’m writing. I have some values stored in an array, and I have written a function that includes checking if one of the keys in that array has a certain value. One function then hooks intowp_head
, and another is filtered bythe_content
except that it doesn’t work as it is.Hopefully the code will help explain more, this is the function that hooks into
wp_head
:function my_function() { if(is_single() && $MyOptions['mykey'] == 'true') { echo "blah blah" . $MyOptions['myotherkey'] . "blah"; } else {} }
If I remove the
&& $MyOptions...
and leave it with justis_single
, it works fine, except that this time$MyOptions['myotherkey']
isn’t echoed, just the blah will show. I know that these keys have values in the array as I have used print_r/echo on the plugin admin page to make sure.My plugin is kind of dependent on this, and I have no idea why including
$MyOptions['mykey'] == 'true'
would stop anything, and I’ve checked other plugins and seen this work.What is it that I need to do to get this to work?
Thanks in advance, just ask if you need more info.
- The topic ‘Problems with actions and filters’ is closed to new replies.