Custom Field from Page ID
-
So I have the following code.
function field_func($atts) { global $post; $name = $atts['name']; if (empty($name)) return; return get_post_meta($post->ID, $name, true); } add_shortcode('field', 'field_func');
This lets me use the shortcode, [field name=’fieldname’] to display the value for that custom field of the current page. However, how would I display the custom field of another post/page on this page with an ID? What code needs to be added so that I can pass [field name=’fieldname’] a second parameter of ~ id=’pageid’ ~?
- The topic ‘Custom Field from Page ID’ is closed to new replies.