Title: Pages Custom Fields
Last modified: August 20, 2016

---

# Pages Custom Fields

 *  [ulozilla](https://wordpress.org/support/users/ulozilla/)
 * (@ulozilla)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/pages-custom-fields/)
 * I haven’t been able to load the custom fields of my page template, there’s documentation
   about how to call Posts custom fields , but nothing about Pages, ¿How you call
   these on a page?, do you HAVE to call them inside the loop? what if i have a 
   text located on a certain place of the screen(not were the loop is located) and
   i want to show that custom field?.

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/pages-custom-fields/#post-2134555)
 * > How you call these on a page?
 * Exactly the same way that you call them in a post.
 * > do you HAVE to call them inside the loop?
 * No – as long as you can pass a post or page id to the function, you should be
   able to use it anywhere.
 *  [Peter Hardy-vanDoorn](https://wordpress.org/support/users/petervandoorn/)
 * (@petervandoorn)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/pages-custom-fields/#post-2134680)
 * If you call the custom field routine within the loop using the standard structure
   of `get_post_meta($post->ID, 'nameoffield', true)` then it will be addressing
   the post’s ID from the loop.
 * The way to use the page’s ID is to first save the ID in a variable _before_ the
   loop begins (eg, at the top of your php add `<?php $thispage = get_the_ID(); ?
   >` ) and then within the loop you can get the custom field with `get_post_meta(
   $thispage, 'nameoffield', true)`
 * Another way of doing it, of course, would be to save all of the page’s custom
   fields into variables before the loop and then you won’t have to use `get_post_meta`
   within the loop itself, thus avoiding confusion if you’re also pulling in post
   custom fields too.
 * Hope that helps
 * Peter
 *  Thread Starter [ulozilla](https://wordpress.org/support/users/ulozilla/)
 * (@ulozilla)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/pages-custom-fields/#post-2134727)
 * Thanks Peter, that looks like a nice workaround
 *  Thread Starter [ulozilla](https://wordpress.org/support/users/ulozilla/)
 * (@ulozilla)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/pages-custom-fields/#post-2134733)
 * I’ve tried the example Peter mentioned, i can get the custom fields of the page
   but only using `<?php the_meta();?>` , i’ve saved the page id before the loop
   and then inserted the `get_post_meta($thispage, 'nameoffield', true)` code, but
   it’s not working, maybe i need something else to make it work? any tips?
 *  Thread Starter [ulozilla](https://wordpress.org/support/users/ulozilla/)
 * (@ulozilla)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/pages-custom-fields/#post-2134740)
 * it’s working now =) , thanks just had to add :
 * `<?php echo get_post_meta($thispage, 'nameoffield', true) ?>`

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

The topic ‘Pages Custom Fields’ is closed to new replies.

 * 5 replies
 * 3 participants
 * Last reply from: [ulozilla](https://wordpress.org/support/users/ulozilla/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/pages-custom-fields/#post-2134740)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
