wordpress

//template url  <?php bloginfo(‘template_url’); ?>

<?php //dynamic menu
//wp_nav_menu( array(‘menu’=>’Home’,’container’=>”,’link_before’=>'<span>’,’link_after’=>'</span>’));
$menus=wp_get_nav_menu_items(‘Home’);
if($menus && count($menus)>0){
echo ‘<ul>’;
foreach($menus as $menu){
echo ‘<li ‘;
if($menu->object_id==$_REQUEST[‘page_id’] || $menu->object_id==$_REQUEST[‘redirect’]) echo ‘ class=”active” ‘ ;

echo ‘><a href=”‘ . $menu->url . ‘”><span>’ . $menu->title . ‘ </span></a></li>’;

}
echo ‘</ul>’;
}
?>

<?php //pagelist by id
//wp_list_pages(‘title_li=&depth=1&sort_column=menu_order’);
$menu_page_id = $post->ID;
$post_det = get_post($menu_page_id,ARRAY_A);

$headerMenues = get_pages(‘parent=0&sort_column=menu_order&number=5’);
foreach($headerMenues as $headerMenue){
$titlearr = explode(‘ ‘,$headerMenue->post_title);
if(count($titlearr) > 1){
$title_last = array_pop($titlearr);
$title = implode($titlearr,’ ‘).’ <b>’.$title_last.'</b>’;
}else
$title = $headerMenue->post_title;
if($menu_page_id == $headerMenue->ID || $headerMenue->ID == $post_det[‘post_parent’]){
echo ‘<li class=”page_item current_page_item”>
<a title=”Portfolio” href=”‘.get_permalink($headerMenue->ID).'”><i>’.$title.'</i></a>
</li>’;
}else{
echo ‘<li class=”page_item”>
<a title=”Portfolio” href=”‘.get_permalink($headerMenue->ID).'”><i>’.$title.'</i></a>
</li>’;
}
}
?>

//add extrafield in post page admin section

<?php
/*
Plugin Name: Meta Box Example
Plugin URI: http://wp.tutsplus.com/
Description: Adds an example meta box to wordpress.
Version: None
Author: Christopher Davis
Author URI: http://wp.tutsplus.com/
License: Public Domain
*/

add_action( 'add_meta_boxes', 'cd_meta_box_add' );
function cd_meta_box_add()
{
	add_meta_box( 'my-meta-box-id', 'My First Meta Box', 'cd_meta_box_cb', 'post', '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] ) : '';
	$selected = isset( $values['my_meta_box_select'] ) ? esc_attr( $values['my_meta_box_select'][0] ) : '';
	$check = isset( $values['my_meta_box_check'] ) ? esc_attr( $values['my_meta_box_check'][0] ) : '';
	wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
	?>
	<p>
		<label for="my_meta_box_text">Text Label</label>
		<input type="text" name="my_meta_box_text" id="my_meta_box_text" value="<?php echo $text; ?>" />
	</p>

	<p>
		<label for="my_meta_box_select">Color</label>
		<select name="my_meta_box_select" id="my_meta_box_select">
			<option value="red" <?php selected( $selected, 'red' ); ?>>Red</option>
			<option value="blue" <?php selected( $selected, 'blue' ); ?>>Blue</option>
		</select>
	</p>
	<p>
		<input type="checkbox" name="my_meta_box_check" id="my_meta_box_check" <?php checked( $check, 'on' ); ?> />
		<label for="my_meta_box_check">Don't Check This.</label>
	</p>
	<?php	
}

add_action( 'save_post', 'cd_meta_box_save' );
function cd_meta_box_save( $post_id )
{
	// Bail if we're doing an auto save
	if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;

	// if our nonce isn't there, or we can't verify it, bail
	if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;

	// if our current user can't edit this post, bail
	if( !current_user_can( 'edit_post' ) ) return;

	// now we can actually save the data
	$allowed = array( 
		'a' => array( // on allow a tags
			'href' => array() // and those anchords can only have href attribute
		)
	);

	// Probably a good idea to make sure your data is set
	if( isset( $_POST['my_meta_box_text'] ) )
		update_post_meta( $post_id, 'my_meta_box_text', wp_kses( $_POST['my_meta_box_text'], $allowed ) );

	if( isset( $_POST['my_meta_box_select'] ) )
		update_post_meta( $post_id, 'my_meta_box_select', esc_attr( $_POST['my_meta_box_select'] ) );

	// This is purely my personal preference for saving checkboxes
	$chk = ( isset( $_POST['my_meta_box_check'] ) && $_POST['my_meta_box_check'] ) ? 'on' : 'off';
	update_post_meta( $post_id, 'my_meta_box_check', $chk );
}
?>

Adding Extra Fields to the WordPress User Profile

Just add the code t your theme’s functions.php file, or create a functions.php file if you don’t already have one.
<?php
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );

function extra_user_profile_fields( $user ) { ?>
<h3><?php _e("Extra profile information", "blank"); ?></h3>

<table>
<tr>
<th><label for="address"><?php _e("Address"); ?></label></th>
<td>
<input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" /><br />
<span><?php _e("Please enter your address."); ?></span>
</td>
</tr>
<tr>
<th><label for="city"><?php _e("City"); ?></label></th>
<td>
<input type="text" name="city" id="city" value="<?php echo esc_attr( get_the_author_meta( 'city', $user->ID ) ); ?>" /><br />
<span><?php _e("Please enter your city."); ?></span>
</td>
</tr>
<tr>
<th><label for="province"><?php _e("Province"); ?></label></th>
<td>
<input type="text" name="province" id="province" value="<?php echo esc_attr( get_the_author_meta( 'province', $user->ID ) ); ?>" /><br />
<span><?php _e("Please enter your province."); ?></span>
</td>
</tr>
<tr>
<th><label for="postalcode"><?php _e("Postal Code"); ?></label></th>
<td>
<input type="text" name="postalcode" id="postalcode" value="<?php echo esc_attr( get_the_author_meta( 'postalcode', $user->ID ) ); ?>" /><br />
<span><?php _e("Please enter your postal code."); ?></span>
</td>
</tr>
</table>
<?php }

add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );

function save_extra_user_profile_fields( $user_id ) {

if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }

update_user_meta( $user_id, 'address', $_POST['address'] );
update_user_meta( $user_id, 'city', $_POST['city'] );
update_user_meta( $user_id, 'province', $_POST['province'] );
update_user_meta( $user_id, 'postalcode', $_POST['postalcode'] );
}
?>
http://kortmannsttravel.com/wp-content/themes/sohohotel/includes/plugins/