Add input field to ‘Pages > Edit Page’ through functions.php

functions.php // Add custom Slider ID field to ‘Edit Page’ add_action( ‘add_meta_boxes’, ‘cd_meta_box_add’ ); function cd_meta_box_add() { add_meta_box( ‘my-meta-box-id’, ‘Slider’, ‘cd_meta_box_cb’, ‘page’, ‘normal’, ‘high’ ); } function cd_meta_box_cb( $post ) { $values = get_post_custom( $post->ID ); $text = isset( $values[‘my_meta_box_text’] ) ? esc_attr( $values[‘my_meta_box_text’][0] ) : ”; wp_nonce_field( ‘my_meta_box_nonce’, ‘meta_box_nonce’ ); ?> <p> <label for=”my_meta_box_text”>Add … Read more

Custom field losing p tags on display

Add this to your functions.php file: add_filter( ‘meta_content’, ‘wptexturize’ ); add_filter( ‘meta_content’, ‘convert_smilies’ ); add_filter( ‘meta_content’, ‘convert_chars’ ); add_filter( ‘meta_content’, ‘wpautop’ ); add_filter( ‘meta_content’, ‘shortcode_unautop’ ); add_filter( ‘meta_content’, ‘prepend_attachment’ ); Then use this code to pull in the result: <?php $story_content = get_post_meta($post->ID, ‘story’, true); echo apply_filters(‘meta_content’, $story_content); ?>

Save page data to an xml file

The save_post hook gets called each time a post is created or updated. Just hook into that. There you can do something like fputcsv(‘/tmp/’ . $post_id, $post) or output to XML/JSON. == EDIT == add_action( ‘save_post’, ‘wp239s5_post_to_xml’, 10, 2 ); function wp239s5_post_to_xml( $post_id, $post ) { if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return … Read more

Extra filed under “About the user” user profile

Add following code in theme’s functions.php file. add_action( ‘show_user_profile’, ‘extra_user_profile_fields’ ); add_action( ‘edit_user_profile’, ‘extra_user_profile_fields’ ); function extra_user_profile_fields( $user ) { ?> <table class=”form-table”> <tr> <th><label for=”address”><?php _e(“Designation”); ?></label></th> <td> <input type=”text” name=”designation” id=”designation” value=”<?php echo esc_attr( get_the_author_meta( ‘designation’, $user->ID ) ); ?>” class=”regular-text” /><br /> </td> </tr> <tr> <th><label for=”city”><?php _e(“Linked In”); ?></label></th> <td> <input … Read more