Support » Plugin: Meta Box - WordPress Custom Fields Framework » mb custom fields not showing front end

  • Resolved fabgrim

    (@fabgrim)


    Hello,

    I have an issue that drives me a bit nuts at the moment, could you pleqse help?
    I read the documentation, i serached the forum, but i still dont understand what i am missing.

    I got the function.php all right on my 2017 template, all is displayed back end.

    Then i pasted the code for the front end into single.php as follows but nothing is showing. I also did it in template/content.php, still nothing works

    Thanks a lot for your thoughts…

    Here is my code for SINGLE.PHP
    <?php
    /**
    * The template for displaying all single posts
    *
    * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
    *
    * @package WordPress
    * @subpackage Twenty_Seventeen
    * @since 1.0
    * @version 1.0
    */

    get_header(); ?>

    <div class=”wrap”>
    <div id=”primary” class=”content-area”>

    <main id=”main” class=”site-main” role=”main”>

    <?php

    /* Start the Loop */
    while ( have_posts() ) :
    the_post();

    get_template_part( ‘template-parts/post/content’, get_post_format() );

    $value = rwmb_meta( $field_id );
    echo $value;

    // If comments are open or we have at least one comment, load up the comment template.
    if ( comments_open() || get_comments_number() ) :
    comments_template();
    endif;

    the_post_navigation(
    array(
    ‘prev_text’ => ‘<span class=”screen-reader-text”>’ . __( ‘Previous Post’, ‘twentyseventeen’ ) . ‘</span><span aria-hidden=”true” class=”nav-subtitle”>’ . __( ‘Previous’, ‘twentyseventeen’ ) . ‘</span> <span class=”nav-title”><span class=”nav-title-icon-wrapper”>’ . twentyseventeen_get_svg( array( ‘icon’ => ‘arrow-left’ ) ) . ‘</span>%title</span>’,
    ‘next_text’ => ‘<span class=”screen-reader-text”>’ . __( ‘Next Post’, ‘twentyseventeen’ ) . ‘</span><span aria-hidden=”true” class=”nav-subtitle”>’ . __( ‘Next’, ‘twentyseventeen’ ) . ‘</span> <span class=”nav-title”>%title<span class=”nav-title-icon-wrapper”>’ . twentyseventeen_get_svg( array( ‘icon’ => ‘arrow-right’ ) ) . ‘</span></span>’,
    )
    );

    endwhile; // End of the loop.
    ?>

    </main><!– #main –>
    </div><!– #primary –>
    <?php get_sidebar(); ?>
    </div><!– .wrap –>

    <?php
    get_footer();

    /////——-//////
    AND FOR FUNCTION.PHP

    function offer_meta_box( $meta_boxes ) {
    $prefix = ‘edelweiss-‘;

    $meta_boxes[] = array(
    ‘id’ => ‘jobreference’,
    ‘title’ => esc_html__( ‘Reference poste’, ‘Postes ouverts’ ),
    ‘post_types’ => array(‘post’ ),
    ‘priority’ => ‘default’,
    ‘autosave’ => ‘true’,
    ‘fields’ => array(
    array(
    ‘id’ => $prefix . ‘reference’,
    ‘type’ => ‘number’,
    ‘name’ => esc_html__( ‘Reference:’, ‘Postes ouverts’ ),
    ‘attributes’ => array(),
    ‘step’ => ‘1’,
    ),
    array(
    ‘id’ => $prefix . ‘statut’,
    ‘name’ => esc_html__( ‘Statut:’, ‘Postes ouverts’ ),
    ‘type’ => ‘radio’,
    ‘placeholder’ => ”,
    ‘options’ => array(
    ‘Ouvert’ => ‘Ouvert’,
    ‘Fermé’ => ‘Fermé’,
    ),
    ‘inline’ => ‘true’,
    ‘std’ => ‘Ouvert’,
    ),
    array(
    ‘id’ => $prefix . ‘lieu’,
    ‘type’ => ‘text’,
    ‘name’ => esc_html__( ‘Lieu’, ‘Postes ouverts’ ),
    ‘size’ => 50,
    ),
    array(
    ‘id’ => $prefix . ‘langues’,
    ‘type’ => ‘text’,
    ‘name’ => esc_html__( ‘Langues:’, ‘Postes ouverts’ ),
    ‘size’ => 50,
    ),
    array(
    ‘id’ => $prefix . ‘seniorite’,
    ‘type’ => ‘text’,
    ‘name’ => esc_html__( ‘Seniorité:’, ‘Postes ouverts’ ),
    ),
    array(
    ‘id’ => $prefix . ‘mobilit’,
    ‘type’ => ‘text’,
    ‘name’ => esc_html__( ‘Mobilité requise:’, ‘Postes ouverts’ ),
    ‘size’ => 10,
    ),
    array(
    ‘id’ => $prefix . ‘descriptionposte’,
    ‘type’ => ‘textarea’,
    ‘name’ => esc_html__( ‘Description de poste:’, ‘Postes ouverts’ ),
    ‘rows’ => 20,
    ),
    array(
    ‘id’ => $prefix . ‘typeclient’,
    ‘name’ => esc_html__( ‘Type de client:’, ‘Postes ouverts’ ),
    ‘type’ => ‘select’,
    ‘placeholder’ => esc_html__( ‘Select an Item’, ‘Postes ouverts’ ),
    ‘options’ => array(
    ‘final’ => ‘Client final’,
    ‘consulting’ => ‘Société de consulting’,
    ),
    ‘std’ => ‘final’,
    ),
    array(
    ‘id’ => $prefix . ‘typeposte’,
    ‘name’ => esc_html__( ‘Type de poste:’, ‘Postes ouverts’ ),
    ‘type’ => ‘select’,
    ‘placeholder’ => esc_html__( ‘Select an Item’, ‘Postes ouverts’ ),
    ‘options’ => array(
    ‘permanent’ => ‘Poste permanent’,
    ‘contrat’ => ‘Contrat’,
    ),
    ‘std’ => ‘permanent’,
    ),
    ),
    );

    return $meta_boxes;
    }
    add_filter( ‘rwmb_meta_boxes’, ‘offer_meta_box’ );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Anh Tran

    (@rilwis)

    In you “single.php” file, please replace the “$field_id” with your real field ID (which can be “edelweiss-reference” or “edelweiss-statut”, etc.):

    $value = rwmb_meta( $field_id );
    echo $value;
    fabgrim

    (@fabgrim)

    Thanks Ahn, it seems to be working well now.

    I am having an issue with single.php though, as the articles must always feature a contact form that includes a file upload zone.
    I need it below the article.

    I am using caldera, for any reason the file upload area would not show (I’m talking about the last version of file uploader), despite it is a copy paste of a form that works well in my other pages.
    This a copy paste of same code.

    If I want to manually include the caldera form as a short code in my article, it will always be above the metabox.

    Exporting/pasting the form code, or including the command render form in single.php does not work either.

    So if you have an idea, it is more than welcome …

    Thanks a lot for your help !

    Best,
    Fabian

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.