• Resolved thelumberjack

    (@thelumberjack)


    Hello, fellow WordPressers!

    On my site, I am using an Ajax based contact form. Here is a small extract from my contact-page.php page template (I’ve excluded the inputs).

    <form method="post" action="<?php echo get_template_directory_uri(); ?>/contact.php" name="contactform" id="contactform"></form>

    To define the address in which enquiries are sent, you edit the following line in contact.php.

    $address = 'email@website.com';

    When the address is defined like above, the form works perfectly. However, I would like it to automatically update when the site’s main address changes. I am trying the following.

    $address = get_bloginfo('admin_email');

    Unfortunately, this isn’t working. I am getting the following error message.

    Fatal error: Call to undefined function get_bloginfo() in /home/beardsqu/public_html/website.com/wp-content/themes/mytheme/contact.php on line 95

    Does anybody know why it’s not working?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • My guess would be that contact.php is not invoking all of the various WordPress loading actions, so that function (and any other WordPress function) is unavailable when you try to use it through AJAX.

    Try adding require_once( '../../../wp-load.php' ) at the top of contact.php and see if that makes a difference.

    Thread Starter thelumberjack

    (@thelumberjack)

    Thanks so much, it worked.

    You my friend are a freakin’ Godsend!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problems With get_bloginfo’ is closed to new replies.