• I’ve got some custom meta boxes set-up and I’d like the user to be able to enter data into that, then use a shortcode to display that data in the content area (User goes to create a page, fills in whatever info they want in the editor, hops down to the custom meta boxes fills in that info, then places a shortcode at the beginning of the content area.

    First, is this possible? And second, I’ve hobbled together the code below that I thought may work based on a tutorial I found on custom fields, but I get a white screen when I try implementing it.

    https://pastebin.com/PvJMd6wS

    Any help, or nudges in the right direction would be much appreciated. Thanks!

Viewing 1 replies (of 1 total)
  • Try this out. I used this code to display image, and text from custom post meta box’s.

    function display_custom_meta($atts, $content = NULL){
     global $post;
     extract( shortcode_atts(array(
    
     'param' => '',
    
     ),$atts));
    
     $post_meta = get_post_meta($post->ID,'_meta_contet',TRUE);
    
     return '<div>'.$post_meta['post_meta_box_name'].'</div>';
    
    }
    add_shortcode('display_custom_meta','display_custom_meta');

    Change the meta name’s to what you need to , but this should work fine you have custom post meta on you page.

Viewing 1 replies (of 1 total)
  • The topic ‘Using shortcodes to display post meta data within a page’ is closed to new replies.