Home Forums General Issues Fatal error: Call to undefined function has_sub_field()


Fatal error: Call to undefined function has_sub_field()

  • Hello.
    I was assigned to install and set up WPML on one of our clients’ sites. I did, and everything was going great, until the site suddenly stopped working properly.
    This is how it looks in the browser:
    This url however, makes the site work as intended (The id is of the main parent page titled “Velkommen”):

    The site is using wordpress 3.5.

    Apart from the errors above, I also noticed this in the source code:

    The code it is referring to is this:

    <div class=”submenu”>


    $i = 1;

    if (get_sub_field(“title”) && $i != 1) {
    echo ‘<a
    onclick=”_gaq.push([\’_trackPageview\’, \’/’ . strip_tags(get_sub_field(“title”)) . ‘\’]);”
    data-url=”‘ . sanitize_title_with_dashes(get_sub_field(“title”)) . ‘-section’ . ‘”>’ . strip_tags(get_sub_field(“title”)) . ‘‘;


    What can I do? Tips are well appreciated!

  • Hi @preben89

    Looks like ACF isn’t installed. That would explain why the has_sub_field function is not defined.

    Either that, or you have an old version of ACF which does not have this function…

  • Thank you for your reply.
    It is supposed to be installed, and working. I didn’t do anything to the ACF plugin before the error appeared. All I did was deleting a translated version/copy of the main parent page.

    It is supposed to be installed and active:

    The translation of the page “Velkommen” is the one I deleted:

    Would you suggest I reinstall the ACF plugin, or something similar? Or anything else?

  • I have not gotten the same error any more, (The function has_sub_field()) but I still get this error.

    Notice: Trying to get property of non-object in /var/www/ on line 29

    Any clues? (I have attached the entire source code for the page with the error. The error appears on line 142. I don’t think post-template.php has been altered at all. I have compared it with other wordpress sites)
    I have also attached the frontend index of the working page.

  • Hi @preben89

    It is looking like this issue is not related to the ACF pluginbut more of an issue in your theme or core WP.

    Can you switch themes and do some debugging before you ask me to look over your files?


  • I’m sorry. It seems the bug was caused by a combination of the site using ACF, and WPML not being fully compatible with it. (According to support staff at WPML)

    My solution was duplication the site 2 times. One to remove the errors and WPML, and one to make a translated version.

    Thank you for your help.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Fatal error: Call to undefined function has_sub_field()’ is closed to new replies.