0

I'm working on a wordpress website created quite long ago. In the header file I see the following code:

<?php
 query_posts("page_id=63");
 while ( have_posts() ) : the_post()
 ?>
 <?php echo get_post_meta($post->ID, 'Header Info1', true) ; ?> 
 <?php
 endwhile; 
 wp_reset_query();
 ?> 

I need to modify the phone number which I believe would be done by modifying the "Header Info1" being retrieved as a signle post from the id 63. I checked the page having ID 63 but there is nothing related to "Header Info1"

My question is: Where are the custom fields of get_post_meta located? Where can I find "Header Info1" to change it?

0

You can do it either by editing the database table wp_postmeta: searching for the post_id = 63 and meta_key = 'Header Info1', and then editing the meta_value value.

The other, probably easier option, is to call a function update_post_meta(), like this:

<?php
query_posts("page_id=63");

while ( have_posts() ) : the_post();

    update_post_meta( get_the_ID(), 'Header Info1', 'new value' );

    echo get_post_meta( get_the_ID(), 'Header Info1', true ); 

endwhile; 
wp_reset_query();

Remember to remove that line after updating the meta field.

But doing this through code or editing the DB table probably beats the purpose of the using meta fields for additional dynamic post/page content.

Therefore, you might want to use some plugin which provides you with the GUI for editing the values of additional fields. Feel free to search for 'wordpress custom meta fields plugin', there are some great easy to use solutions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.