Custom Post Types in Wordpress

By // No comments:
CUSTOM POST TYPES

<?php
register_post_type('snippet',array(
 'public' => true,
 'label' => 'Snippet',
 'labels' => array(
  'add_new_item' => 'Add New Snippet'
  ),
 'supports' => array('title','editor','comments','thumbnail','excerpt')
 ));
?>

TO CREATE CATEGORIES & TAGS
<?php
'taxonomies' => array('category','post_tag')

add_action('init','custom_post_type');
?>

NEW TAXONOMY
<?php
add_action('init',function(){
register_taxonomy('language','snippet',array(
 'label' => 'Language'
 ));
});
?>

RESAVE PERMALINKS TO DISPLAY CUSTOM POST TYPES

TO DISPLAY TAXONOMY FOR CUSTOM POST TYPES
<?php
echo get_the_term_list(get_the_id(),'language','',',');
?>

TO DISPLAY TAGS
<?php the_tags(); ?>

Register Jquery Javascript files

By // No comments:
REGISTER JQUERY JAVASCRIPT FILES
<?php
function load_my_scripts(){
 wp_register_script('jquery', get_template_directory_uri().'/jquery.min.js');
 wp_register_script('my_lightbox', get_template_directory_uri().'/js/lightbox.js', array('jquery'));
 wp_register_script('my_gallery', get_template_directory_uri().'/js/gallery.js', array('jquery'));

 wp_enqueue_script('my_lightbox');
 wp_enqueue_script('my_custom');
}
add_action('wp_enqueue_scripts','load_my_scripts');
?>

WordPress include

By // No comments:
<?php include(TEMPLATEPATH.'/mygallery/header-include.php'); ?>

HEADER-INCLUDE.PHP
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/mygallery/lightbox.css">

Responsive codes

By // No comments:
RESPONSIVE CODES

<meta name="viewport" content="width=device-width">

@media only screen and (min-width: 1px) and (max-width: 650px){
 
}

WordPress Theme code

By // No comments:
WordPRess theme

<?php bloginfo('template_url' ); ?>/images/logo.jpg

WP MENU
<?php wp_nav_menu(array('theme_location' => 'primary')); ?>

SITE URL
<?php bloginfo('url'); ?>

SHORTCODE
<?php echo do_shortcode('[shortcode]'); ?>

FUNCTIONS.PHP => CTRL+F => SIDEBAR => COPY PASTE WIDGET CODE
name => (change name)
ID => (change ID)
description => (change DESC)

/* <?php dynamic_sidebar('ID'); ?> */
<?php dynamic_sidebar('sidebar-4'); ?>

FUNCTIONS.PHP => FIND => MENU
<? register_nav_menu('footer_menu'__( 'Footer Menu', 'twentytwelve')); ?>
IN FOOTER ADD THIS TO SHOW FOOTER MENU 
<?PHP wp_nav_menu(array('theme_location' => 'footer_menu')); ?>

CODE FOR POSTS LOOP
<?php
$posts = new WP_Query(array(
 'posts_per_page' => 5, //-1 for unlimited posts
 'offset' => 0, //starting posts from zero
 'category_name' => 'events', //events is category slug
 'post_type' => 'post',
 'post_status' => 'publish'
 ));
if($posts -> have_posts()):
 while ($posts -> have_posts()): $posts -> the_post(); ?>
  <h2><?php the_title(); ?></h2>
  <?php the_excerpt(); ?>
  <?php the_post_thumbnail(); ?>
  <a href="<?php the_permalink(); ?>">Read more</a>
 <?php endwhile;
 
else:
echo "No posts here";

endif;
wp_reset_query();
?>

Next and Previous Buttons

By // No comments:
NEXT AND PREVIOUS BUTTONS

<?php
if(isset($_REQUEST['ind']))
 $sind = $_REQUEST['ind'];
else
 $sind = 0;
$totrec = 5;
mysql_connect("localhost","root","");
mysql_select_db("information_schema");
$data = mysql_query("select * from character_sets limit $sind, $totrec");
while($rec=mysql_fetch_row($data)){
 echo "<tr><td>$rec[0]<td>$rec[1]<td>$rec[2]";
}
echo "</table>";
if($sind!=0){
 $pind = $sind - $totrec;
 echo "<a href='demo.php?ind=$pind'>Previous</a>";
}
$nind = $sind + $totrec;
echo "<a href='demo.php?ind=$nind'>Next</a>";

//to stop display next button on last page
$data1 = mysql_query("select * from character_sets");
$trec = mysql_num_rows($data1);
if($nind < $trec){
 echo "next";
}
?>

Upload file to database

By // No comments:
UPLOAD FILE TO DATABASE

<form method="post" action="" enctype="multipart/form-data">
 Select file: <input type="file" name="f1">
 <input type="submit" name="sub" value="UPLOAD">
</form>
<?php
if(is_uploaded_file($_FILES['f1']['tmp_name'])){
 mysql_connect("localhost","root","");
 mysql_select_db("test");
 $cont = file_get_contents($_FILES['f1']['tmp_name']);
 $cont = addslashes($cont);
 if(mysql_query("insert tbl_images values ('','$cont')"))
  echo "Image added";
 else 
  echo "not";
}
?>