Support

Account

Home Forums ACF PRO Display specific text when field is empty

Solved

Display specific text when field is empty

  • Hello
    I have a field for displaying youtube video and i would like to display a message like : no video” when this field is empty

    i tried this

    function woo_new_product_tab_content() {
    
     
    	
    	
    	// The new tab content
    	
    	
    	
    	//echo '<h2>New Product Tab</h2>';
    	//echo '<p>Here\'s your new product tab.</p>';
            echo get_field('video_link', $post_id);
    	echo $youtubevideo_code = wp_oembed_get( get_field('video_link') );
    	
    	if($youtubevideo_code) {
        echo '<b>No video </b>';
       // echo $materia;
    }
    	

    but doesnt work
    any ideas please?
    Many thanks

  • 
    $youtubevideo_code = get_field('video_link', $post_id);
    if ($youtubevideo_code) {
      // show video
    } else {
      // show no video message
    }
    
  • Many thanks John:) works perfect!

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

The topic ‘Display specific text when field is empty’ is closed to new replies.