Saving metadata of related post on save_post
Saving metadata of related post on save_post
Saving metadata of related post on save_post
Yes this is possible. If you’re adding a custom field by a meta box you could do like this: // add action to create your custom field add_action( ‘add_meta_boxes’, ‘create_meta_box’ ); // add a callback that will be called when saving the post add_filter( ‘save_post’, ‘save_meta_box’, 10, 2 ); // function that will create a … Read more
You should use Advanced Custom Fields. If I understand what you want to do correctly, you can add a Select Field with Radio Buttons, and then build conditional Page Link and Text (for the URL) Fields that appear based on the Select Field button. You would then build an if/else statement in the code: <?php … Read more
I would first loop over $lista and generate a new array of data that only has non-empty values. Now you can check $values to ensure there is data and output your title: function opening_hours_custom_fields() { global $post; if ( $lista = genesis_get_custom_field( ‘_happy_day’, $post->ID ) ) { $values = array(); foreach ( $lista as $value … Read more
Its not exactly clear on where you are going, and why you are going there? If you want to place the file.pdf at the location www.mysite.com/page-name/ go for it. Use your File Transfer Protocol (FTP) tool to create that subdirectory on your server, dump your file there, then refer to it via the proper url … Read more
Use the project name in the meta key field & the amount donated as the meta value, and I would suggest using update_user_meta rather than add_user_meta because reasons. Something like this: $project=”donated_to_” . $project; update_user_meta( $user_id, $project, $amount ); Apply some sort of logic before setting those variables – you know, in case the user … Read more
How to save dynamically generated value in post type?
Where you put it depends, you likely want to put the get_post_meta() call: echo get_post_meta( get_the_ID(), ‘_custom_field’, true ) ); into the according template file. But of course you can also hook into a filter or action from your functions.php or a plugin.
display some fields in custom post backend
Should be easy enough. First, get the City. <?php $city = get_field(‘city’); ?> Then in your WP_Query, insert the taxonomy parameter: <?php $loop = new WP_Query( array( ‘post_type’ => ‘member’, ‘posts_per_page’ => -1, ‘location’ => $city ) ); ?> Et Vilola: you only get the Members that have the taxonomy $city.