Using Custom Fields In Functions
-
Hey,
This is my first go at posting here but I’m having a problem.
I have moderate PHP knowledge but here is basically what I’m trying to do:Inside my template/theme, let’s say page.php, I am trying to set up a function that displays a custom field, but the name of the custom field is the variable.
So right now it looks like this at the top of page.php:
function contentitem($number) { echo "<h3>"; echo get_post_meta($post->ID, "Name$number", true); echo "</h3>"; }then below, where I want it displayed, I have:
contentitem("1"); contentitem("2");So far it isn’t grabbing that variable and using it in the function though. Maybe it is just a syntax error but I’m not sure. Thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Using Custom Fields In Functions’ is closed to new replies.