Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Sidebars & Widgets (http://forum.bytesforall.com/forumdisplay.php?f=14)
-   -   [SOLVED] Error in PHP Coding Using PHP Text Widget (http://forum.bytesforall.com/showthread.php?t=4102)

rnimchuk Oct 28, 2009 07:47 AM

[SOLVED] Error in PHP Coding Using PHP Text Widget
 
This should be simple but for some reason it is not. I am using Executable PHP widget to place some coding within a right inner sidebar. I created a custom field named "callout_text" that is used to display a sentence or two as a callout of the current post. Within the widget, the code I am placing is:

<?php callout_text(); ?>

However, when displaying the page, I get the following error message:

Fatal error: Call to undefined function callout_text() in /home/content/r/p/n/rpnimchuk/html/wp/wp-content/plugins/php-code-widget/execphp.php(37) : eval()'d code on line 1

What the heck am I doing wrong? BTW I am using Custom Post Limits to limit the home page to a single post. I am also using WP 2.8.5 and the latest version of Atahualpa.

Thanks!

Bob Nimchuk

juggledad Oct 28, 2009 10:51 AM

when you use the syntax 'xxx()' php believes that you are calling the function 'xxx' so somewhere in the code there hast be
HTML Code:

function xxx(parms) {
  some
  code
  goes
  here
  }

the error is saying that php can't find the callout_text function

rnimchuk Oct 28, 2009 12:26 PM

Thanks Juggledad. Found the error of my ways. I needed to place the following code in the widget:

<?php
global $post;
echo get_post_meta($post->ID, "callout_text", true);
?>


Because this is contained within a widget you also need to declare the scope (global $post) to return the information. This works great for how I want to display part of blog's content as call out text.

Bob


All times are GMT -6. The time now is 09:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.