• Resolved umsuka

    (@umsuka)


    Hi All

    I am having problems displaying my custom fields on the front end of the website.

    Any help please.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Some more information on what the problem is would be helpful.

    Are you using a custom fields plugin or the built in WordPress custom fields.

    I would check out these likes on how to display custom fields on websites.
    http://codex.ww.wp.xz.cn/Using_Custom_Fields

    For the plugin check out this. http://www.advancedcustomfields.com/

    Thread Starter umsuka

    (@umsuka)

    Hi Matthew

    Thanks for your response , I am using meta box plugin to try and display info on front end.

    I downloaded the demo.php as described here https://metabox.io/docs/getting-started/

    See code below for the custom fields file

    <?php
    /**
    * Registering meta boxes
    *
    * All the definitions of meta boxes are listed below with comments.
    * Please read them CAREFULLY.
    *
    * You also should read the changelog to know what has been changed before updating.
    *
    * For more information, please visit:
    * @link http://metabox.io/docs/registering-meta-boxes/
    */
    add_filter( ‘rwmb_meta_boxes’, ‘th_register_meta_boxes’ );
    /**
    * Register meta boxes
    *
    * Remember to change “your_prefix” to actual prefix in your project
    *
    * @param array $meta_boxes List of meta boxes
    *
    * @return array
    */
    function thambo_register_meta_boxes( $meta_boxes )
    {
    /**
    * prefix of meta keys (optional)
    * Use underscore (_) at the beginning to make keys hidden
    * Alt.: You also can make prefix empty to disable it
    */
    // Better has an underscore as last sign
    $prefix = ”;
    // 1st meta box
    $meta_boxes[] = array(
    // Meta box id, UNIQUE per meta box. Optional since 4.1.5
    ‘id’ => ‘standard’,
    // Meta box title – Will appear at the drag and drop handle bar. Required.
    ‘title’ => __( ‘Project Details’, ‘your-prefix’ ),
    // Post types, accept custom post types as well – DEFAULT is ‘post’. Can be array (multiple post types) or string (1 post type). Optional.
    ‘post_types’ => array( ‘post’ ),
    // Where the meta box appear: normal (default), advanced, side. Optional.
    ‘context’ => ‘normal’,
    // Order of meta box: high (default), low. Optional.
    ‘priority’ => ‘high’,
    // Auto save: true, false (default). Optional.
    ‘autosave’ => true,
    // List of meta fields
    ‘fields’ => array(
    // Youtube Video ID // OEMBED
    array(
    ‘name’ => __( ‘Youtube Video ID’, ‘thambo_’ ),
    ‘id’ => “th_yt”,
    ‘desc’ => __( ‘Youtube Video ID’, ‘thambo_’ ),
    ‘type’ => ‘oembed’,
    ),

    // Flickr Album ID
    array(
    ‘name’ => __( ‘Flickr Album ID’, ‘thambo_’ ),
    ‘id’ => “th_fr”,
    ‘desc’ => __( ‘Flickr Album ID’, ‘thambo_’ ),
    ‘type’ => ‘oembed’,
    ),

    )
    );

    return $meta_boxes;
    }

    The above code shows 2 custom fields on the post page. With the youtube one I can get the video to show up on the post. With flickr I am having problems.

    The below code is supposed to show on the loop-single page.

    <article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>

    <h2 class=”post-title”><?php the_title(); ?></h2>

    <div class=”entry clearfix”>

    <?php the_content(); ?>

    <div class=”multimedia”>

    <h3>Multimedia Content</h3>

    <p class=”multimedia-content”>

    <?php global $post;
    $video = get_post_meta( $post->ID, ‘th_youtube’, true );
    echo $embed_code = wp_oembed_get( $video ); ?>

    </p>
    <p class=”flikr_album”>

    Flicker Album // Flickr album will display here

    </p>

    </div>

    </div>
    </article>

    The above code is on the single post level, its supposed showing the content , youtube video and flickr.

    Rgds

    Bongani

    I would try contacting them in there WordPress support forum. https://ww.wp.xz.cn/support/plugin/meta-box#postform

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Meta Box Front end Display’ is closed to new replies.