Add custom field to all posts in specific category

You can use WordPress functions to do this and just run it once, a fast example would be. function wpse_85236_add_photo_field(){ global $post; $photoquery = new WP_Query(‘posts_per_page=-1’); while ( $photoquery->have_posts() ) : $photoquery->the_post(); if ( in_category( ‘photography’ )) { add_post_meta($post->ID, ‘category’, ‘photography’, true); } endwhile; } add_action( ‘init’, ‘wpse_85236_add_photo_field’ ); Remember to remove the function after … Read more

Guest Author – How can I use custom fields to create guest author link?

Remove the filters and the function used in the tutorial you linked and replace them with this code: add_filter( ‘get_the_author_user_url’, ‘guest_author_url’ ); add_filter( ‘the_author’, ‘guest_author_link’ ); add_filter( ‘get_the_author_display_name’, ‘guest_author_name’ ); function guest_author_url($url) { global $post; $guest_url = get_post_meta( $post->ID, ‘guest-url’, true ); if ( filter_var($guest_url, FILTER_VALIDATE_URL) ) { return $guest_url; } elseif ( get_post_meta( $post->ID, … Read more

Backend search; include CPT meta?

Untested, but the following should work: add_action( ‘posts_clauses’, ‘wpse110779_filter_admin_search’, 10, 2 ); function wpse110779_filter_admin_search( $pieces, $query ){ global $wpdb; //Check if this is the main query,and is a search on the admin screen if( $query->is_search() & $query->is_admin() && $query->is_main_query() ){ //Collect post types & search term $post_types = $query->get(‘post_type’); $search = $query->get(‘s’); //Check if query … Read more

Custom Meta Field not Working with qTranslate [closed]

Less complicated is to use the plugin’s Quicktags and use the Gettext functions to print the content in the site. [:en]English[:pt]Português Quicktags docs Another option is to do just like qTranslate interface does with the post titles: Create one custom field for each language in your meta box: qTrans documentation is not consolidated, so analyzing … Read more

Add custom meta box on Post page

You need to use the add_meta_box function add_action( ‘add_meta_boxes’, ‘my_custom_meta_box’ ) ); function my_custom_meta_box(){ $args = array(); add_meta_box( ‘my_metabox_id’, __( ‘My Meta Box’, ‘my_textdomain’ ), // Title ‘my_callback_function’, // Callback function that renders the content of the meta box ‘post’, // Admin page (or post type) to show the meta box on ‘side’, // Context … Read more

How to update serialized data in the user meta data

Thats just PHP serialized array notation. You would get that same result by this code: $meta_value = array( ‘alumni’ => ‘Yes’, ‘donations_collected’ => ’10’ ); update_user_meta( $team_member_id, ‘wp_s2member_custom_fields’, $meta_value); So if you want to then change the donations_collected value to 11: $meta_value = get_user_meta( $team_member_id, ‘wp_s2member_custom_fields’, true ); $meta_value[‘donations_collected’]++; update_user_meta( $team_member_id, ‘wp_s2member_custom_fields’, $meta_value);

Plugin to auto convert custom fields to tag

Placing something like this in your functions.php should work. I haven’t had the opportunity to test this code yet and its a little messy (could be polished up) but should give you an very good starting point.. add_action(‘save_post’,’custom_field_add_tags’); function custom_field_add_tags($post_id) { $post = get_post($post_id); //get values of custom fields and put into array $tag1 = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)