In the following code:<?php echo "codice alloggio: ",get_the_ID(), colormag_entry_meta(); ?> How could I add metadata values after get_the-ID? In particular I'd like to call the value of the meta key"function_number", you can see this meta also in this code:

update_post_meta( $post_id, "function_number", $number );

In my functions.php file

  • Do you mean how do you read the value you set with update_post_meta( $post_id, "function_number", $number ); ? That's get_post_meta( $post_id, "function_number" ). Else I'm not sure what you're asking. What is colormag_entry_meta() ? Is that from a plugin, or your theme?
    – Rup
    Jun 10 at 16:11
  • And just to check what you're doing with the update_post_meta: as a rule you shouldn't be making database changes like that from templates. You don't want to be writing to your database on page loads if possible, from a database load point of view and also because it'll make the site harder to cache. Is this details of accommodation a customer has just booked?
    – Rup
    Jun 10 at 16:13
  • @Rup update_post_meta is in the functions.php file, I wrote it just to make understand the function name, but unluckily get_post_meta( $post_id, "function_number" ) is not working :( It's a detail of all accomodations and it should appear near the post ID (accomodation code) and other meta data like number of guests and number of bedrooms Jun 10 at 19:32
  • @Rup Colormag is my main theme, but I use a child theme Jun 12 at 5:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.