My custom widget won’t stay in the widget area after I refresh the widget page

ID Base should be passed to WP_Widget class constructor as shown in the following code, You have passes wrong id “example-widget” which does not match with “id_base”, also don’t add spaces in id base. Replace MY_Widget() function with following modified function and it will work. function MY_Widget() { $widget_ops = array( ‘classname’ => ‘example’, ‘description’ … Read more

How to use in_category?

It looks like you’re mixing the WordPress in_category() function with plugin / theme code that isn’t setting up a standard WP Query or post object. So you can’t use in_category(). Use var_dump($content); and var_dump($data); to see if either of those objects have a ‘category’ property for the content. Use that in an if statement instead, … Read more