Support

Account

Home Forums General Issues Call get field in the function.php

Helping

Call get field in the function.php

  • Hi,
    I have create a description field and i want to call this in the header with this code :

    
    // meta description 
    
    function wpse_custom_meta_description() 
    {
    
        if ( ! is_single() )
            return;
    
        $desc = get_field('meta_description');
    
        // Output
        if( ! empty( $desc ) )
            printf( 
                '<meta name="description" content="%s" />',
                esc_attr( trim( $desc ) )
            );
    }
    add_action( 'wp_head', 'wpse_custom_meta_description' , 2 );
    
     // meta description 
    

    But $desc is umpty !
    Who to do ? Thankyou

  • The code I created works very well, it will not pose any problem in the future is it right?

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

You must be logged in to reply to this topic.