Title: Theme function in functions.php
Last modified: August 20, 2016

---

# Theme function in functions.php

 *  Resolved [50020](https://wordpress.org/support/users/50020-1/)
 * (@50020-1)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/theme-function-in-functionsphp/)
 * I have created a function in the theme functions.php
 * >  function display_techincal_info() {
   >  // code here echo “Blah Blah Blah” }
 * and I call the functions in my template pages using
 * > <?php display_techincal_info(); ?>
 * but it doesn’t call the function. Not being 100% aux fait with how wordpress 
   works, I added the code
 * > add_action( ‘init’, ‘display_techincal_info’ );
 * as I had done for my custom posts, but that didn’t work either. Now I know there
   is nothing wrong with the code within the function becuase I am currently using
   it already on the same page. I just now wish to use it on more than one page –
   so it makes sense making it a function, and calling it from all the pages I wish
   to display the output….
 * How do I declare the function in functions.php and how do I call it?
 * thanks…

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [auday1982](https://wordpress.org/support/users/auday1982/)
 * (@auday1982)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/theme-function-in-functionsphp/#post-2506761)
 * use return to return a value from the function …
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/theme-function-in-functionsphp/#post-2506783)
 * please paste the real code of your function into a [http://pastebin.com/](http://pastebin.com/)
   and post the link to it here;
 * youy example should work;
    however, your real code might not generate any output.
 *  Thread Starter [50020](https://wordpress.org/support/users/50020-1/)
 * (@50020-1)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/theme-function-in-functionsphp/#post-2506924)
 * Hi,
 * thanks.
 * The full function is posted on [pastebin here](http://pastebin.com/H5wDjDgF)
 *  Thread Starter [50020](https://wordpress.org/support/users/50020-1/)
 * (@50020-1)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/theme-function-in-functionsphp/#post-2506929)
 * RESOLUTION
 * I added non-conditional output to the function, and indeed the function does 
   get called, AND the non conditional output was output.
 * so it appeared that the $post->ID wasn’t available. A google search for “custon
   fields from functions.php’ lead me to find that $post needs to be declared as
   a global variable before I can use it. Might be obvious now, but it wasn’t to
   me at first!
 * so added the code:
 * > global $post ;
 * to the function. Hey presto!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Theme function in functions.php’ is closed to new replies.

 * 4 replies
 * 3 participants
 * Last reply from: [50020](https://wordpress.org/support/users/50020-1/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/theme-function-in-functionsphp/#post-2506929)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
