Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4342686
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:39:04+00:00 2026-05-21T11:39:04+00:00

I am pulling my hair out. I have created some simple functions that generate

  • 0

I am pulling my hair out. I have created some simple functions that generate random numbers, pulled from a database that I want to use on wordpress pages. (And then call them from the theme files, such as header.php or page.php.)

I have tried putting the functions inside functions.php that is in the theme (as per the documentation I have read), but I keep getting the “call to undefined function” errors! What in the world am I doing wrong?

Example, here is a function inside the functions.php

function randomPollNumber() {
///this gets a random active poll number
    $sql12 = "SELECT id FROM poll WHERE removed = 0 AND active = 1 ORDER BY RAND() LIMIT 1";
    $result12 = mysql_query($sql12);
    $myrow12 = mysql_fetch_row($result12);
    $pollquestionid = $myrow12[0];
    return $pollquestionid;
}

And I am calling it, from the header.php file with this

<?php echo randomPollNumber(); ?>

And yes, I DID try using the if_function_exists, but of course it cannot FIND the function, so of course it does not exist. Please help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:39:04+00:00Added an answer on May 21, 2026 at 11:39 am

    Very strange – some debugging tips:

    1. Put die(‘functions.php file loaded’) statement at the beginning of functions.php (not inside a function). If it doesn’t die, you know the file isn’t being loaded.
    2. If it dies, then check your spelling (copy and paste the function name from functions.php into your echo […]). It’s amazing how many times I’m SURE I’ve spelt it right, when in fact I haven’t.
    3. If it doesn’t die, check that your file is definitely called functions.php, that it’s definitely inside the right theme folder for the theme you are coding.
    4. It’s possible that the functions.php file has an error in it, and so is not being parsed, hence WordPress can’t find the function. Check your logs for errors. Load the functions file and nothing else, and check that the function is working. Are you using PHP Unit or something like that?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been pulling my hair out. I have a very simple postgre database, one
Pulling my hair out with this simple CSS layout. I have a 2-column fixed
I'm pulling my hair out over this. I have this bit of javascript that
I'm pulling my hair out over this one. I have an app that when
I have been pulling my hair out trying to do some dynamic div resizing
Pulling my hair out over this one. I have one wordpress install at /2009
I have been pulling my hair out about this since Friday and I am
I have been pulling my hair out trying to figure out what I can't
I have been pulling my hair out trying to make this work. I have
I'm pulling my hair out with my mysql server. I have wampserver installed, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.