Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Deprecation WordPress

  • SOLVED

I am given to understand that the following code is deprecated:

<form method="get" action="<?php bloginfo('home'); ?>/">

Would somebody tell me what the new code should be.

Thanks

Answers (4)

2014-07-17

timDesain Nanang answers:

should be

<form method="get" action="<?php echo home_url(); ?>">


timDesain Nanang comments:

codex:
[[LINK href="http://codex.wordpress.org/Function_Reference/home_url"]]http://codex.wordpress.org/Function_Reference/home_url[[/LINK]]
Samples:

echo home_url();
// Output: http://www.example.com

echo home_url('/');
// : http://www.example.com/

echo home_url($path = '/', $scheme = https);
// Output: https://www.example.com/

echo home_url($path = 'example', $scheme = relative);
// Output: /example


for security, you need add sanitizing URLs: esc_url (like Arnav Joy said.)
http://codex.wordpress.org/Function_Reference/esc_url

echo esc_url(home_url());


timDesain Nanang comments:

another samples:

echo home_url('path-to-page');
// Output : http://www.example.com/path-to-page

//or else, with same output
echo home_url('/path-to-page');
// Output : http://www.example.com/path-to-page

2014-07-17

Arnav Joy answers:

you can use use following

<form method="get" action="<?php esc_url( home_url( '/' )); ?>">

2014-07-17

Sachindra Narayan answers:

its depracated since wp version 2.2... you can use <?php bloginfo('url'); ?> or <?php echo home_url(); ?>

2014-07-17

Hariprasad Vijayan answers:

Hi,

<blockquote>bloginfo('home') - Deprecated since version 2.2. Echo home_url(), or use bloginfo('url').</blockquote>

For reference : [[LINK href="http://codex.wordpress.org/Function_Reference/bloginfo"]]http://codex.wordpress.org/Function_Reference/bloginfo[[/LINK]]