Fatal error: Call to undefined function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GJM
Forum Newbie
Posts: 10
Joined: Fri May 01, 2009 3:25 am

Fatal error: Call to undefined function

Post by GJM »

At this very moment I am attempting to play with the "Types" plugin for Wordpress.

The Types Fields API page here:
http://wp-types.com/documentation/functions/
suggests the following syntax:

Code: Select all

<?php echo(types_render_field("field-slug", array("arg1"=>"val1","arg2"=>"val2"))); ?>
I thought I use their first example and create an image field called "product image" with a field slug "productimage"

So i entered this into my "custom-functions.php" file:

Code: Select all

echo (types_render_field("productimage", array("alt"=>"product image","width"=>"300","height"=>"200","proportional"=>"true")));
and promptly got this error:
Fatal error: Call to undefined function types_render_field() in /public_html/wp-content/themes/dynamik/custom-functions.php on line 10
so I defined the function as such (& trying to follow best practices) I used this:

Code: Select all

function typestest () {
	return (types_render_field("productimage", array("alt"=>"product image", "width"=>"300","height"=>"200","proportional"=>"true")));
}
echo typestest ();
and I still get the same error message.

I am guessing that this is more a PHP problem as I think that I am putting the code into the correct file within wordpress as it is throwing an error code.

My understanding was that it was not really the best form to be using 'echo' within a function which is why I used return, and then called for the function using echo.
I realize that I probably have several errors here, but any assistance would be greatly appreciated as I wrap my brain around using PHP.

Thanks again in advance.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Fatal error: Call to undefined function

Post by califdon »

Quick reply, until someone experienced with Wordpress may come along:

That error message means that it could not find a function named types_render_field, which I must assume, should be part of Wordpress, so my first guess is that your Wordpress library is either not being initiated or is missing that function.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Fatal error: Call to undefined function

Post by requinix »

califdon wrote:That error message means that it could not find a function named types_render_field, which I must assume, should be part of Wordpress, so my first guess is that your Wordpress library is either not being initiated or is missing that function.
I think that's part of this "Types" thing, which apparently is some sort of extension/plugin you have to download (buy?) and install. So I was thinking that maybe it wasn't installed. But I, too, was waiting a bit to see if anyone familiar with WordPress knew the answer.
GJM
Forum Newbie
Posts: 10
Joined: Fri May 01, 2009 3:25 am

Re: Fatal error: Call to undefined function

Post by GJM »

califdon wrote: That error message means that it could not find a function named types_render_field, which I must assume, should be part of Wordpress, so my first guess is that your Wordpress library is either not being initiated or is missing that function.
Thanks for the reply califdon.

I am still very new to php coding. Forgive me if I am not wording this correctly, but, I have added the function call as best as I know how to write it and i have checked with my theme's forum on 'where' to put the call.

Because of the error that was being thrown, it appeared to be HOW I have written the php code which is why I posted it here.

Does the 'syntax' that I have used look like I have it correct?

I have done a fair bit of reading and watched a number of videos, and I think I've followed the 'best practises' but again, I am very new to php.

Any comments on how I have written the code would be appreciated.

Thanks.
GJM
Forum Newbie
Posts: 10
Joined: Fri May 01, 2009 3:25 am

Re: Fatal error: Call to undefined function

Post by GJM »

requinix wrote:..... So I was thinking that maybe it wasn't installed.
Thanks for the reply requinix.

Yes I have it installed and Activated. I actually uninstalled and reinstalled it just to be sure. I am pretty sure it is how I have written the code. That is why I was hoping to have someone look at how I have written it here.

Any suggestions would be welcome.
Post Reply