How to set status codes such as 401 and 403?

The same way you would in any other PHP program: header(“HTTP/1.1 401 Unauthorized”); exit; WordPress has special handling for 404 because there’s a 404 template. Usually if something happens such as a 401, there is no special template, but you can make use of wp_die which will show a message in a simple UI header(“HTTP/1.1 … Read more

Configuring WP-CLI on Windows 10

Actually, I figured out how to do this, and it’s actually really easy to do! Which is awesome because I think it’s a great simple way to work! First up, you don’t want to change the PATH for PHP in bash. So you’ll want to remove that. Instead, what you are doing is using bash … Read more

HTML table from shortcode with multiple parameters

I have created an example of how you can achive what you are after: You can use it like this : [itable data=”inv;coin;coinamount;currency#inv;coin;coinamount;currency”] function itable_shortcode( $atts ) { extract( shortcode_atts( array( ‘data’ => ‘none’, ), $atts ) ); $data = explode(‘#’,$data); $output = “”; foreach ($data as $value) { $output .= ‘<tr>’; $in_value = explode(‘;’,$value); … Read more

user_id error: Only variables should be passed by reference

There is an answer for your question right in the Codex: The first parameter of get_comment function is: $comment – (integer) (required) The ID of the comment you’d like to fetch. You must pass a variable containing an integer (e.g. $id). A literal integer (e.g. 7) will cause a fatal error (Only variables can be … Read more

fallback image for featured image

Your code looks OK and it should work just fine. But there are some things you can (and you should) fix. 1. You don’t use absolute URL for your fallback image You pass /wp/wp-content/themes/klicknet-theme/images/testbild.png as src of your image. It would be much better and more secure if you’d use WP functions in there. For … Read more

Type hinting and void return question

Callback functions for anaction hook don’t need to return anything, so based on the description here: A void return type has been introduced. Functions declared with void as their return type must either omit their return statement altogether, or use an empty return statement. NULL is not a valid return value for a void function. … Read more