• I already created the custom fields in function.php and I am trying to make it show in the frontend of short-description.php

    The custom fields I created in function.php works perfectly in other pages (such as meta.php, etc) but it just doesn’t work on short-description.php

    The code that I currently have in short-description.php is

    <?php
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    
    global $post;
    if ( ! $post->post_excerpt ) {
    	return;
    } ?>
    <div itemprop="description">
    	<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
    
         <?php $technical_id = get_post_meta($post->ID, '_technical-drawing', true); if( !empty( $technical_id ) ){ echo '<a href="'.$technical_id.'"><img src="private/pdf.png" width="25px"></a>  Technical Drawing', ""; }?>
    
         <?php $instructions_id = get_post_meta($post->ID, '_operating-instructions', true); if( !empty( $instructions_id ) ){ echo '<a href="'.$instructions_id.'"><img src="private/pdf.png" width="25px"></a>  Operating Instructions', "
    
    "; }?>
    
    	<?php $qty_id = get_post_meta($post->ID, '_qty', true); if( !empty( $qty_id ) ){ echo '<b>Qty  </b>'.$qty_id, ""; }?>
        <?php $color_id = get_post_meta($post->ID, '_color', true); if( !empty( $color_id ) ){ echo '<b>Color  </b>'.$color_id, ""; }?>
        <?php $size_id = get_post_meta($post->ID, '_size', true); if( !empty( $size_id ) ){ echo '<b>Size  </b>'.$size_id, ""; }?>
    
    </div>

    I should also mention that the ONLY way to get my custom fields to show IS IF I post and input something in the “Product Short Description”. If I post something and save the Product Short Description, that is the only way to get the rest of the custom fields I created to show in the frontend of the page. Please help me and thank you.

    If I post the same exact custom fields I created for meta.php or other frontend pages, it will show perfectly. It just doesn’t show on short-description.php

    https://www.ads-software.com/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom field does not show in frontend’ is closed to new replies.