Wp Remote get with manual redirect

Taking a look at the WordPress HTTP API, it seems there ain’t no simple way to do this. In fact, it might even be a calling for a trac ticket. See, although it allows you to specify the maximum number of redirects, there’s no abstract option to control if redirects should even be followed. So … Read more

wp_remote_post sends empty body

The following code worked source. The ‘Content-Type’ => ‘application/json’ header was missing causing the problem $url=”myAPIURL HERE”; $username=”apiuser”; $password = ‘passwd’; $headers = array( ‘Authorization’ => ‘Basic ‘ . base64_encode( “$username:$password” ), ‘Content-Type’ => ‘application/json’ ); $fields = array( ‘body’ => json_encode( array( ’email’ => ‘[email protected]’, ‘name’ => ‘Pixelbart’, ‘password’ => ‘Pass#your!word’ ) ), ‘headers’ … Read more

How can I call specific function if requested URL is not found?

Simply use template_redirect filter to perform check on request you get in wordpress. add_filter(‘template_redirect’, ‘my_404_override’ ); function my_404_override() { global $wp_query; if (!$wp_query->post) { // Check if any post is found. If not its 404. status_header( 200 ); $wp_query->is_404=false; // Create post object $my_post = array( ‘post_title’ => ‘My post’, ‘post_content’ => ‘This is my … Read more