Home>

The custom field is displayed as local, but not in the production environment.
Custom field settings are arranged locally and in production.

Custom field Field name: temp-info Type: Select Choices yes: Yes no: No

<? php $temp_info = get_post_meta (get_the_ID (), "temp-info", true);?>
<? php if ($temp_info == "yes"):?>
                <section>
                     ">
                        ">
                    
                </section>
<? php endif;?>
var_dump ($temp_info)
the_field ('temp-info')


When you execute, the value changes locally.
string (3) "yes" yes

However, the value does not change in production.
string (0) ""

In such cases
What other methods should I use to find the cause?

  • Answer # 1

    The problem is in the function of another partial loop

    wp_reset_postdata ();


    It was because ID was not correctly acquired by get_the_ID () because it was not described.
    (Because I kept other ids)

    I was looking for problems locally, but I learned thatwp_reset_postdata ();is very important.

Related articles