简体   繁体   中英

home_url() links in wordpress site is getting redirected to some other url

I have developed a website in wordpress (wordpress 3.5) Initially all the links were like : http://localhost:1053/wp Later, to make it accessible from other computers (outside the intranet), I mapped it with a url something like : http://somesite.com/wp

I have changed the WordPress Address (URL) and Site Address (URL) in the settings->general page in admin area. I have also changed the links in navigation (wherever required).

Now, the issue is that when I click on the logo (link), it redirects me to some other url ( http://somesite.com:1053/wp ). This happens with the action of search form also.

I have used <?php echo home_url(); ?> <?php echo home_url(); ?> in the href. When I check it in the page source, the href shows http://somesite.com/wp But it still gets redirected to http://somesite.com:1053/wp

Every other relative link is working fine.

I don't understand what is wrong.

Any help will be appreciated.

Thanks

[SOLVED]

I solved the issue by replacing the statement <?php echo home_url(); ?> <?php echo home_url(); ?> with this <?php echo esc_url( home_url( '/' ) ); ?> <?php echo esc_url( home_url( '/' ) ); ?> .

Run this bad boy: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

It will run a full find and replace on your database (old url to new url), as well as updating the length of the serialized arrays. Just make sure you delete it when you're done!

I solved this by replacing

<?php echo home_url(); ?>

by

<?php echo esc_url( home_url( '/' ) ); ?>

It works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM