Adding a custom “Add Custom Field” button to Custom Meta boxes
I suggest to use WP Alchemy Metabox. What you are looking for is the have_fields_and_multi.
I suggest to use WP Alchemy Metabox. What you are looking for is the have_fields_and_multi.
You could use a javascript redirect to for passing the appropriate query_params. Checkout WP’s default widgets file for the categories dropdown widget. When you select a new category, it automatically refreshes the page and redirects you to the archive for that category. I used this same trick (or code for that matter!) to change the … Read more
Quick search shows that related part of form is generated by meta_form() function. Start from there I guess. Also note that you will need to retrieve from source and submit nonce that protects that form. I am not sure if submitting single field invalidates the nonce there, but that also might be the case.
To are still call database inside the by get_post_meta() where you already have the values in $custom_fields variable. Try something like this: <?php $custom_fields = get_post_custom($post->ID); for ($i = 1; $i <= 4; $i++) { if(isset($custom_fields[“rw_location_$i”][0])){ if($i==1){ echo ‘<h1>’;} else {echo ‘<h2>’;} echo $custom_fields[“rw_location_$i”][0] if($i==1) {echo ‘</h1>’; }else {echo ‘</h2>’}; } } ?> If I … Read more
not sure what you are doing wrong, your code looks ok at first glance … make sure you represent yes and no as string values … if ( ‘yes’ == $provenance_mb->get_the_value( ‘docposs’ ) ) { echo “If you wish to make”; } else if ( ‘no’ == $provenance_mb->get_the_value( ‘docposs’ ) ) { echo “an apple … Read more
To get a value of a single custom field use <?php $post_id = $post->ID; $key = ‘value’; // change value to what custom field you are looking for // To retrieve only the first value of given key $customfield = get_post_meta($post_id, $key, ‘true’); // To use as default $customfield = get_post_meta($post_id, $key); // Then check … Read more
This article will get you there: http://andrewferguson.net/2008/09/26/using-add_meta_box/
First off, you should consider using using the building WordPress functionality rather than linking straight to a PHP file. Anyone could game that very easily and artificially vote up posts. To use the wordpress ajax functionality, send your ajax request to yoursite.com/wp-admin/admin-ajax.php, and use standard plugin hooks system. Tollmanz’s response is right on: your update … Read more
You are trying to echo within a variable. You also have encapsulated PHP tags in the string as well. You need to concatenate just the functions themselves like this: function default_content($content) { global $post; if ($post->post_type == ‘my-custom-post-type’) { $content .= ‘<p style=”text-align: center;”><strong>Custom Field Text here: ‘. get_post_meta( $post->ID, “custom-field-1”, true ).'</strong></p> <p style=”text-align: … Read more
First of all, save_post has an argument $post_id, so there’s no need to global $post. In some cases, $post might not actually be set (anymore) when you do this, which is probably why it breaks. Second, you should probably check whether you’re storing a revision or not (see below). So your code should look like … Read more