• I have added the code for custom fields to my child’s functions.php and see the field in the back end. Just can not figure out how to call them in the template or tpl?

    I see you have string replacements for things like Title and such. Does a string replacement need to be added to the display function?

    Thank you for any help you can lend. I really like your plugin. Great job with it!

    https://wordpress.org/plugins/our-team-by-woothemes/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author James Koster

    (@jameskoster)

    Hey, you can use get_post_meta to grab your custom data. There’s an example of this in the FAQ.

    Take a look at the “I need to add another field, can I do it without touching core files?” section and make sure you followed each step 🙂

    Thread Starter pymarkley

    (@pymarkley)

    Thanks for the reply. I have my function as such.

    add_filter( 'woothemes_our_member_fields_display', 'my_new_fields_display' );
    function my_new_fields_display( $member_fields ) {
        global $post;
              $expertise = esc_attr( get_post_meta( $post->ID, '_expertise', true ) );
              if ( '' != $expertise ) {
              $member_fields .= '<li class="expertise">' . $expertise . '</li><!--/.expertise-->' . "\n";
              }
              return $member_fields;
              }

    I put <?php echo $expertise; ?> in my tpl string and nothing is displayed. Only the %%-%% entries. Here is my template function.

    function new_team_member_template( $tpl ) {
    $tpl = ‘ <div itemscope itemtype=”http://schema.org/Person&#8221; class=”%%CLASS%%”>
    <div class=”flip-container” ontouchstart=”this.classList.toggle(\’hover\’);”>
    <div class=”flipper”>
    <div class=”front”>
    %%AVATAR%% %%TITLE%%
    <div id=”team-member-%%ID%%” class=”team-member-infoicon” itemprop=”description”>
    <img class=”infoicon” src=”/wp-content/uploads/2014/04/i-logo.jpg”>
    </div>
    </div>
    <div class=”back”>
    %%TITLE%% <div class=”team-info”>EXPERTISE: <?php echo $expertise; ?> <P>CONNECT: <P>VCARD: </div>
    <img class=”team-learn-more” src=”/wp-content/uploads/2014/04/learnmorel-button.jpg”>
    <div id=”team-member-%%ID%%” class=”team-member-infoicon” itemprop=”description”>
    <img class=”infoicon” src=”/wp-content/uploads/2014/04/i-logo.jpg”>
    </div>
    </div>
    </div>
    </div>

    </div>’;
    return $tpl;
    }

    `

    Thread Starter pymarkley

    (@pymarkley)

    I also have the custom field function as well. That all is working and I can add info to the field in the admin area.

    // Add Custom Fields to team member page
    
    add_filter( 'woothemes_our_team_member_fields', 'my_new_fields' );
    function my_new_fields( $fields ) {
        $fields['expertise'] = array(
                'name'              => __( 'Expertise', 'our-team-by-woothemes' ),
                'description'       => __( 'Expertise Info', 'our-team-by-woothemes' ),
                'type'              => 'text',
                'default'           => '',
                'section'           => 'info'
              );
              return $fields;
              }
    Plugin Author James Koster

    (@jameskoster)

    Sorry, I’m afraid I can’t do this for you. Please copy paste the code exactly as it appears in the FAQ then change it one step at a time to see where you’re going wrong.

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

The topic ‘Call Custom Field in Template’ is closed to new replies.