Populate a custom field dropdown with post titles by author

here: What you need is to create a meta box so first you use the add_meta_box() // Hook into WordPress add_meta_boxes action add_action( ‘add_meta_boxes’, ‘add_Businesses_custom_metabox’ ); /** * Add meta box function */ function add_Businesses_custom_metabox() { add_meta_box( ‘custom-metabox’, __( ‘Businesses’ ), ‘Businesses_custom_metabox’, ‘events’, ‘side’, ‘high’ ); } here you can see that i used “events” … Read more

How can I combine this php statement to get the results of multiple variable inputs?

If you are using WP 3.1, I would recommend using the meta_query parameter with the WP_Query class. $args = array( “meta_query’ => array( array( ‘key’ => $customkey1, ‘value’ => $customvalue1, ‘compare’ => ‘=’ ), array( ‘key’ => $customkey2, ‘value’ => $customvalue2, ‘compare’ => ‘=’ ) ) ); $query = new WP_Query( $args ); if ( … Read more

Edit multiple custom post types while saving a new or edited post

here is how i would do that: add_action(‘save_post’,’update_all_meta’); function update_all_meta($post_id){ // verify if this is an auto save routine. // If it is our form has not been submitted, so we dont want to do anything if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; //check for post type if ( $post->post_type != “YOUR_CUSTOM_TYPE” ) … Read more

echo get_post_meta of all post in a category to fill up a select field

Thank you very much for your answers! I finally found what I wanted here : http://sixrevisions.com/wordpress/custom-fields-search/ Here is the code : <form name=”search” action=”” method=”get”> <select name=”City”> <?php $metakey = ‘city’; $cities = $wpdb->get_col($wpdb->prepare(“SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC”, $metakey) ); if ($cities) { foreach ($cities as $city) … Read more

How can I use custom properties to set different background on different pages?

You get custom field values with get_post_meta(). WordPress has a function called wp_localize_script() that’s used to, as the name suggests, localized scripts by creating a javascript object from a PHP array. When you use wp_enqueue_script() to add a script to the front end of wordpress, you can “localize” it by calling wp_localize_script() afterwards. If you … Read more

saving meta/custom field to tag

you can use wp_insert_term() to create the tag and then wp_set_object_terms() to set it as the custom post tag: //get the tag $tag = $_POST[‘ad_Tags’]; //create the tag $term_id= wp_insert_term( $tag, // the term ‘post_tag’, // the taxonomy array(‘description’=> ‘term description’,’slug’ => ‘term-slug’) ); //set the tag wp_set_object_terms( $post_id, $term_id, ‘post_tag’ );