Support » Plugins » Hacks » Display custom fields for custom post type

  • I’m trying to display on the site custom fields, that are created for custom post type. I have to display “price” and “description”.
    I’ve made file content-user.php:

    $price = get_post_meta( get_the_ID(), 'goods_price', true );
        $excerpt = theme_get_excerpt();
        $descr = array( $price, $excerpt );
        global $post;
            array(  'id' => theme_get_post_id(),
                    'class' => theme_get_post_class(),
                    'thumbnail' => theme_get_post_thumbnail(),
                    'title' => '<a href="' . get_permalink( $post->ID ) . '" rel="bookmark" title="' . strip_tags(get_the_title()) . '">' . get_the_title() . '</a>',
            'heading' => theme_get_option('theme_'.(is_single()?'single':'posts').'_article_title_tag'),
                    'before' => theme_get_metadata_icons( 'category,edit', 'header' ),
                    'content' => $descr,
                    'after' => '' ));

    So I have a word “Array” in the page of single post. If I replace $descr = array( $price, $excerpt ); with $descr =$price; or $descr = $excerpt; I have or price, or description.

    What I need to put in content-user.php to see price and description in the content?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    $descr needs to be a string, your theme wrapper doesn’t know how to deal with arrays, so build a single string out of various elements like so:
    $descr = $price . '<br>' . $excerpt;
    You can rearrange and add or remove HTML as needed to get the desired effect.

Viewing 1 replies (of 1 total)
  • The topic ‘Display custom fields for custom post type’ is closed to new replies.