Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Thanked 0 Times in 0 Posts

    Question Problem dispaying WordPress meta box data

    Can't seem to populate a href in the WordPress theme output with content that is successfully saving to a custom WordPress meta box. Any ideas would be greatly appreicated?

    The problem area is highlighted in bold but the rest of the supporting code is provided in case it holds the answer.

    /* Add Meta Boxes*/
    function reviews_meta_boxes() {
    add_meta_box('reviews_meta', 'Product Details', 'show_custom_meta_box', 'at_reviews', 'normal', 'high');
    add_action('add_meta_boxes', 'reviews_meta_boxes');

    function show_custom_meta_box($post) {
    echo '<input type="hidden" name="custom_meta_box_nonce" value="'. wp_create_nonce('custom_meta_box'). '" />';
    <table class="form-table">
    <tr valign="top">
    <th scope="row" style="width:500px;"><label for="featured_review">Should this product have a featured ribbon? Enter "yes" or "no" without the quote marks...</label></th>
    <td><input type="text" name="featured_review" id="featured_review" value="<?php echo get_post_meta($post->ID, 'featured_review', true)?>" /></td>
    <tr valign="top">
    <th scope="row" style="width:500px;"><label for="product_link">Enter Product (Affiliate) Link Including http:// ...</label></th>
    <td><input type="text" name="product_link" id="product_link" value="<?php echo get_post_meta($post->ID, 'product_link', true)?>" /></td>

    function save_custom_meta_box($post_id) {
    // check nonce
    if (!isset($_POST['custom_meta_box_nonce']) || !wp_verify_nonce($_POST['custom_meta_box_nonce'], 'custom_meta_box')) {
    return $post_id;

    // check capabilities
    if ('post' == $_POST['at_reviews']) {
    if (!current_user_can('edit_post', $post_id)) {
    return $post_id;
    } elseif (!current_user_can('edit_page', $post_id)) {
    return $post_id;

    // exit on autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
    return $post_id;

    if(isset($_POST['featured_review'])) {
    update_post_meta($post_id, 'featured_review', $_POST['featured_review']);
    } else {
    delete_post_meta($post_id, 'featured_review');

    if(isset($_POST['product_link'])) {
    update_post_meta($post_id, 'product_link', $_POST['product_link']);
    } else {
    delete_post_meta($post_id, 'product_link');
    add_action('save_post', 'save_custom_meta_box');

    /* Add Link To Theme */
    function review_layout_footer(){
    if ( 'at_reviews' == get_post_type() ){

    <p><a href="<?php echo get_post_meta($post->ID, 'product_link', true); ?>"><img src="IMAGELINK" alt="Get <?php the_title(); ?> Now" style="margin-left:10px;" /></a></p>
    add_action('thesis_hook_after_post' , 'review_layout_footer');

    Code worked after replacing with the following...

    <?php $postid = get_the_ID(); echo get_post_meta($postid,'product_link', true); ?>
    Last edited by danie; 12-15-2011 at 03:54 AM.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts