Home Forums Front-end Issues get_field is null / trying to display a field on a post skin


get_field is null / trying to display a field on a post skin

  • Hi, im trying to displaying a field on a post widget on an elemenetor post skin.

    On homepage it works, but when the widget is saved as a template on EA advanced tabs, it cant seem to pull the field value at all. Please view and see the What’s hot section (which displays correctly) but the “upcoming parties” section doesnt have the date on the badge of the card.

    Here is what I found out in my code:

    public function render_badge() {
    $value = get_field( 'event_date_field', false );
    $event_date_field = $this->get_instance_value( 'event_date_field' );
    if ( ! empty( $event_date_field ) && function_exists( 'get_field' ) ) {
        $event_date = get_field( $event_date_field );
        if ( ! empty( $event_date ) ) {
            <div class="elementor-post__badge" style="z-index: 9999;">
                <?php echo esc_html( $event_date ); ?>
            // Output the event_date value to the browser console
            echo '<script>console.log("' . $value . '");</script>';

    $value is null, but when going thru the condition $event_date_field shows the value on the badge.

    My widget structure is Widget A (whats hot section) which the widget is directly on the homepage itself, Section Template with Widget B inside it (weekly parties) where the widget is in a template that is in another widget called Advance tabs by EA.

    Im not good with PHP but i assume that the section template is messing up the $this instance.

    But eitherways the $value is null.

    I’ve tried every combination to directly pull the field value, but it only works thru the instance.

    I think one way is to directly pull the field value correctly and populate $value without relying on the instance since the section template is probably “blocking” that or something.

    do let me know if there are any solutions to this! I think its a pretty simple fix, but im not good at PHP at all.

    Thank you in advance

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.