Back to Top

How to allow External domain in WordPress?

Allow External domain in Wordpress

Hello All, Happy New Year 🙂 .In this quick article I will show, how to allow external url/host in wordpress.Recently i was working with wordpress for getting data from external feed url.

So, When I tried to access data from same domain,it was working fine but when i tried to access data from other domain/host, I got following error:

WP HTTP Error: A valid URL was not provided

I googled to get solution for above error in wordpress and what does it mean. This error occur because by default external urls are disabled in wordpress for security reason.So you need to allow external host/domain explicitly using following line of code into your functions.php file or your plugin’s main file:

add_filter( 'http_request_host_is_external', 'allow_external_host', 10, 3 );
function allow_external_host( $allow, $host, $url ) {
	if ( $host == '' ) 
		$allow = true; 
	return $allow; 

Here,I have used http_request_host_is_external filter which is used to check HTTP request is external or not.In condiiton pass your external domain you want to allow.

So that’s it for now from my side. Hope this article will be useful to someone.

Suggested Reading:

Post via e-mail in WordPress
Customize Contact Form 7 in WordPress
User Roles in WordPress

If you have any query or question,tell us in the comment section :). Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to upload file using WordPress

Posted on 6 years ago


How to use jQuery Lazy Load Plugin?

Posted on 5 years ago


How to access Remote File using PHP

Posted on 7 years ago