Trying to use a variable to set image width

There are invalid PHP codes in your sample. Try to use valid PHP code like below. $imageWidth = get_option(‘devotional_imageWidth’,’100%’); $content = “<h2>Devotionally Images</h2>”; $content .= ‘<div style=”width:’ . $imageWidth. ‘;”>’; $content .= ‘<img src=”‘ .$show_file. ‘” alt=”Image Title Here”>’; $content .= “devotional by Devotional.ly”; $content .= ‘</div>’; return $content;

Error establishing a database connection (configuration)

Are you creating WordPress from scratch? You do not need to create the wp-config.php manually. Just open your installed WordPress from your browser and it will run an installer for you. If you migrated from an existing WordPress installation (from another server/PC), check your database settings in wp-config.php file. // ** MySQL settings ** // … Read more

Show sidebar only to author of post

The reason this is not working is because you are trying to use undefined variables, they are declared outside the function and can therefor not be used without prefixing them with the global keyword. If you have error_reporting enabled you would see warnings like this: Notice: Undefined variable: current_user in /… on line 11 Notice: … Read more

How can I change the background color of divs dynamically (depending on an order-status in woocommerce)?

Your issue is a misunderstanding of how CSS/HTML works. Take this example: <style>p { color: red; }</style> <p>1</p> <style>p { color: blue; }</style> <p>2</p> <style>p { color: green; }</style> <p>3</p> Which colour is the 1st paragraph? I suspect you would answer red, but that would be incorrect. All paragraphs are green. The disconnect is that … Read more

Inserting a class on before_widget if checkbox is checked

I eventually use the following to be able to do it: add_filter(‘dynamic_sidebar_params’, function($params) { global $wp_registered_widgets; $this_widget_id = $params[0][‘widget_id’]; $this_widget = $wp_registered_widgets[$this_widget_id]; $widget_object = $this_widget[‘callback’][0]; $all_settings = get_option($widget_object->option_name); $saved_settings = $all_settings[$params[1][‘number’]]; if ($saved_settings[‘myclass’]) { $classe_to_add = ‘myclass ‘; $classe_to_add = ‘class=” ‘.$classe_to_add; $params[0][‘before_widget’] = str_replace(‘class=”‘,$classe_to_add,$params[0][‘before_widget’]); } return $params; });