Custom fields in post title
-
Sorry for my bad English. I have this code to be able to use a shortcode with the custom fields I want in an entry or page.
add_shortcode(‘field’, ‘shortcode_field’); function shortcode_field($atts){ extract(shortcode_atts(array( ‘post_id’ => NULL, ), $atts)); if(!isset($atts[0])) return; $field = esc_attr($atts[0]); global $post; $post_id = (NULL === $post_id) ? $post->ID : $post_id; return get_post_meta($post_id, $field, true); }
The problem is that it does not work for post titles and I would need to add a custom field to the title (in addition to the text you add). And I’m a little lost of how to do it. So I would pray if someone can help me and explain it to me.
Thank you
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Custom fields in post title’ is closed to new replies.