converts your code snippets into pretty-printed HTML format, easily embeddable into blog posts, emails and websites
Off course we all known that there’s lot tutorial and discussion about taxonomies and meta box, and from that i learned. And now i’m trying to create an album video of youtube for my client. Thats why i use taxonomies for author and album then meta box for Youtube ID. And this code is just for reminder of me because i have kind of sortem memory loss, hehe.
add_action('init', 'Narasumber');
function Narasumber() {
register_taxonomy(
'Narasumber',
'post',
array(
'hierarchical' => false,
'labels' => array(
'name' => __( 'Narasumber' ),
'singular_name' => __( 'Narasumber' ),
'search_items' => __( 'Search Narasumber' ),
'popular_items' => __( 'Popular Narasumber' ),
'all_items' => __( 'All Narasumber' ),
'edit_item' => __( 'Edit Narasumber' ),
'update_item' => __( 'Update Narasumber' ),
'add_new_item' => __( 'Add Narasumber' ),
'new_item_name' => __( 'New Narasumber' ),
'menu_name' => __( 'Narasumber' ),
'parent_item' => __('Parent Narasumber'),
'parent_item_colon' => __('Parent Narasumber:')
),
'query_var' => true,
'rewrite' => array('slug' => 'narasumber')
)
);
}
add_action('init', 'Album');
function Album() {
register_taxonomy(
'Album',
'post',
array(
'hierarchical' => false,
'labels' => array(
'name' => __( 'Album' ),
'singular_name' => __( 'Album' ),
'search_items' => __( 'Search Album' ),
'popular_items' => __( 'Popular Album' ),
'all_items' => __( 'All Album' ),
'edit_item' => __( 'Edit Album' ),
'update_item' => __( 'Update Album' ),
'add_new_item' => __( 'Add Album' ),
'new_item_name' => __( 'New Album' ),
'menu_name' => __( 'Album' ),
'parent_item' => __('Parent Album'),
'parent_item_colon' => __('Parent Album:')
),
'query_var' => true,
'rewrite' => array('slug' => 'album')
)
);
}
add_action("admin_init", "YoutubeID_init");
add_action('save_post', 'save_YoutubeID_info');
function YoutubeID_init(){
add_meta_box("YoutubeID-meta", "Youtube ID", "YoutubeID_meta_options", "post", "normal", "high");
}
function YoutubeID_meta_options(){
global $post;
$meta_info = get_post_custom($post->ID);
$YoutubeID = $meta_info["YoutubeID"][0];
echo '
Youtube ID here, example http://www.youtube.com/watch?v=i-MD3beQPwM :
';
}
function save_YoutubeID_info(){
global $post;
update_post_meta($post->ID, "YoutubeID", $_POST["YoutubeID"]);
}
And this is the preview.

Pass variables to a page using the question mark, for example mypage.php?value=hello. Access these variables with the _GET command.
code snippet:
<?php
// for example: thispage.php?word=abracadabra
$val = $_GET['word'];
echo "the word is: $val";
?> sample output:
the word is: abracadabra
<?php
$fn = "news.txt";
if (isset($_POST['content']))
{
$content = stripslashes($_POST['content']);
$fp = fopen($fn,"w") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
}
?>
<center>
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<textarea rows="25" cols="40" name="content"><?php readfile($fn); ?></textarea><br /><br />
<input type="submit" value="Submit">
</form>
</center>
