Home › Forums › General Issues › 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: http://d.pr/i/3cXQ
This url however, makes the site work as intended (The id is of the main parent page titled “Velkommen”): http://d.pr/i/8CI2
The site is using wordpress 3.5.
Apart from the errors above, I also noticed this in the source code: http://d.pr/i/70wu
The code it is referring to is this:
<div class=”submenu”>
<?php
$i = 1;
while(has_sub_field(“sections”))
{
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”)) . ‘‘;}
$i++;
}
?>
</div>
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: http://d.pr/i/kA9K
The translation of the page “Velkommen” is the one I deleted: http://d.pr/i/oWvW
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/fru-k.no/wp-includes/post-template.php 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?
Thanks
E
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.
The topic ‘Fatal error: Call to undefined function has_sub_field()’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.