Tuesday, October 25, 2016

Multiple Select Fields Using Json and Jquery

<!DOCTYPE html>
<html>
<head>
<title>json with JQuery</title>
</head>
<body>
<select id="first">
  <option value="all">All</option>
</select>
<select id="second">
  <option value="all">All</option>
</select>
<select id="third">
  <option value="all">All</option>
</select>
<select id="fourth">
  <option value="all">All</option>
</select>
<select id="five">
  <option value="all">All</option>
</select>

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

<script type="text/javascript">

var Countries = ["India","USA"];

var States = {
"India": ["Andhra Pradesh","Andaman and Nicobar Islands","Arunachal Pradesh","Assam","Bihar","Chandigarh","Chhattisgarh","Dadra and Nagar Haveli","Daman and Diu","Delhi","Goa","Gujarat","Haryana","Himachal Pradesh","Jammu and Kashmir","Jharkhand","Karnataka","Kerala","Lakshadweep","Madhya Pradesh","Maharashtra","Manipur","Meghalaya","Mizoram","Nagaland","Orissa","Pondicherry","Punjab","Rajasthan","Sikkim","Tamil Nadu","Tripura","Uttar Pradesh","Uttaranchal","West Bengal"], 

"USA": ["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","District of Columbia","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"]
};

var Districts = {
"Alabama": ["Nicobar","North and Middle Andaman","South Andaman"],

"Andhra Pradesh": ["East Godavari","West Godavari","Krishna","Guntur","Prakasam","Sri Potti Sri Ramulu Nellore","Srikakulam","Vizianagaram","and Visakhapatnam","Kurnool","Chittoor","YSR Kadapa and Anantapur"]
  };

var Mandals = {

"Nicobar": ["Arong","Big Lapati","Chuckchucha","IAF Camp","Kakana","Kimois","Kinmai","Kinyuka","Malacca","Mus","Perka","Sawai","Small Lapati","Tamaloo","Tapoiming","Teetop"], 

"East Godavari": ["Rajahmundry Urban","Kakinada Urban","Kakinada Rural","Rajahmundry Rural","Amalapuram","Tuni","Samalkota","Mandapeta","Pithapuram","Peddapuram","Ramachandrapuram","Rajanagaram","Kadiam","Thondangi","Ravulapalem","Thallarevu","Kothapalle","Jaggampeta","Korukonda","Prathipadu","Gollaprolu","Yeleswaram","Kothapeta","Karapa","Malikipuram","P.Gannavaram","Katrenikona","Kirlampudi","Alamuru","Sakhinetipalle","Seethanagaram","Pedapudi","Razole","Kajuluru","Anaparthy","Mamidikuduru","Biccavolu","Gokavaram","Mummidivaram","Allavaram"], 

"Krishna": ["Machilipatnam","Penamaluru","Gudivada","Vijayawada Rural","Nuzvid","Jaggayyapeta","Ibrahimpatnam","Nandigama","Gannavaram","Bapulapadu","Kaikalur","Tiruvuru","Vuyyuru","Gampalagudem","Kanchikacherla","Kalidindi","Kankipadu","Mylavaram","Pedana","Mudinepalle","Agiripalle","Vatsavai","Chandarlapadu","Vissannapet","G.Konduru","Musunuru","Pamarru","Unguturu","Pamidimukkala","Challapalle","Chatrai","Movva","Penuganchiprolu","Gudlavalleru","Guduru","Veerullapadu","Kruthivennu","Mandavalli","A.Konduru","Nagayalanka","Bantumilli","Reddigudem","Koduru","Avanigadda","Ghantasala","Thotlavalluru","Nandivada","Mopidevi","Pedaparupudi"],

"Guntur": ["Tenali","Narasaraopet","Mangalagiri","Chilakaluripet H.O. Purushotha Patnam","Bapatla","Sattenapalle","Ponnur","Piduguralla","Macherla","Vinukonda","Repalle","Tadepalle","Dachepalle","Pedakakani","Chebrolu","Nadendla","Tadikonda","Amaravathi","Gurazala","Phirangipuram","Nekarikallu","Duggirala","Rompicherla","Cherukupalle H.O. Arumbaka","Medikonduru","Nizampatnam","Atchampet","Bollapalle","Kollipara","Edlapadu","Krosuru","Kollur","Thullur","Nuzendla","Machavaram","Karempudi","Karlapalem","Nagaram","Bhattiprolu","Pedakurapadu","Rentachintala","Prathipadu","Durgi","Veldurthi","Ipur","Tsundur","Vatticherukuru","Rajupalem","Amruthalur","Vemuru","Muppalla","Pedanandipadu","Kakumanu","Pittalavanipalem","Bellamkonda","Savalyapuram H.O. Kanamarlapudi"]
};

var Villages = {
"Arong": ["Arong","Big Lapati","Chuckchucha","IAF Camp","Kakana","Kimois","Kinmai","Kinyuka","Malacca","Mus","Perka","Sawai","Small Lapati","Tamaloo","Tapoiming","Teetop"],

"Rajahmundry Urban" : ["Rajahmundry Urban","Rajavolu","Torredu"],

"Machilipatnam" : ["Arisepalle","Bhogireddipalle","Borrapothupalem","Buddalapalem","Chilakalapudi"],
"Tenali" : ["Kolakaluru","Nandivelugu","Nelapadu","Pedaravuru"]

};


$.each(Countries, function(key, value) {
$('#first').append($("<option></option>").attr("value",value).text(value));
});          

function changeSelectOption(firstId, secondId, jsonObj){

$(firstId).change(function() {    
   $(secondId).find('option').remove().end().append('<option value="All">All</option>').val('All');    
    $.each(jsonObj[$(this).val()], function(key, value) {   
     $(secondId)
         .append($("<option></option>")
         .attr("value",value)
         .text(value)); 
    });
});
}
changeSelectOption("#first", "#second", States);
changeSelectOption("#second", "#third", Districts);
changeSelectOption("#third", "#fourth", Mandals);
changeSelectOption("#fourth", "#five", Villages);

</script>
</body>
</html>

Saturday, August 13, 2016

Bootstrap Jquery

Tabindex  working with event.charcode


<input type="text" required="required" id="PhoneNumber" name="PhoneNumber"   onkeypress="return event.charCode >= 48 && event.charCode <= 57">

$('input').on("keypress", function(e) {
            /* ENTER PRESSED*/
            if (e.keyCode == 9) {
                /* FOCUS ELEMENT */
                var inputs = $(this).parents("form").eq(0).find(":input");
                var idx = inputs.index(this);

                if (idx == inputs.length - 1) {
                    inputs[0].select()
                } else {
                    inputs[idx + 1].focus(); //  handles submit buttons
                    inputs[idx + 1].select();
                }
                return false;
            }
        });


On mouse over image change 

<span class="imgwrap"><img class="himg" data-alt-src="images/icon_1_h.png" src="images/icon_1.png" ></span>


 var sourceSwap = function () {
        var $this = $(this);
        var newSource = $this.data('alt-src');
        $this.data('alt-src', $this.attr('src'));
        $this.attr('src', newSource);
    }

    $(function () {
        $(' img.himg').hover(sourceSwap, sourceSwap);
    })


/*----- on click menu active -----*/ ( link )

jQuery(function ($) {    $("ul.nav a").click(function(e) {   
         var link = $(this);
            var item = link.parent("li");  

             if (item.hasClass("active")) {       
         item.removeClass("active").children("a").removeClass("active");   
         } else {            
    item.addClass("active").children("a").addClass("active");  
           }
            if (item.children("ul").length > 0) {     

           var href = link.attr("href");          
      link.attr("href", "#");          
      setTimeout(function () {              
       link.attr("href", href);       
         }, 300);        
        e.preventDefault();      
      }     
   }).each(function() {       
     var link = $(this);        
    if (link.get(0).href === location.href) {    
            link.addClass("active").parents("li").addClass("active");  
         //   link.addClass("active").parents("li").addClass("active").closest('ul.collapse').addClass('in');  /* For show drop-down also*/
              return false;         
   }      
  });});
 

Bootstrap side nav dropdown

$('.side-nav li.dropdown').click(function(e){
   // e.preventDefault();
$(this).siblings().find('.in').removeClass('in');
});

Refresh/Reload web page only once

window.onload = function () {
    if (! localStorage.justOnce) {
        localStorage.setItem("justOnce", "true");
        window.location.reload();
    }
}

Match Media query with jquery

if (window.matchMedia('(min-width: 768px)').matches) {
 //  write your code
}else{
         //  write your code
       }


Equal heights for div's with jQuery

$(document).ready(function(){

    // Select and loop the container element of the elements you want to equalise
    $('.container').each(function(){  
      
      // Cache the highest
      var highestBox = 0;
      
      // Select and loop the elements you want to equalise
      $('.column', this).each(function(){
        
        // If this box is higher than the cached highest then store it
        if($(this).height() > highestBox) {
          highestBox = $(this).height(); 
        }
      
      });  
            
      // Set the height of all those children to whichever was highest 
      $('.column',this).height(highestBox);
                    
    }); 
});


/*---- fullcalnder for modal windows ----*/

$('#profileModal').on('shown.bs.modal', function () {
            $("#calendar, #calendar2").fullCalendar('render');
});

$("#calendar, #calendar2").fullCalendar('render');

/*---- Select Select option with show content  ----*/

<select name="addinvoicerid" class="addinvoicerid">

</select>
addinvoiceArray = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
  for (var i = 0; i < addinvoiceArray.length; i++) {
    $(".addinvoicerid").append('<option value=' + addinvoiceArray[i]+ '_' +[i]+ '>' + addinvoiceArray[i] + '</option>');
   }

/*-------------------*/

<select class="form-control" id="selecterId">
  <option value="a" selected>A</option>
  <option value="b">B</option>
  <option value="c">C</option>
  <option value="d">D</option>
</select>
<div class="selectdescwrap">
<div class="selectdesc" id="a">A Content</div>
<div class="selectdesc"  id="b">B Content</div>
<div class="selectdesc"  id="c">C Content</div>
<div class="selectdesc"  id="d">C Content</div>
</div> $(document).ready(function(){
 $(function() {
 $('.selectdescwrap .selectdesc:first-child').show().siblings().hide();  
 $('#selecterId').change(function(){
    $('.selectdesc').hide();
    $('#' + $(this).val()).show();
   });
 });
});

/*---- Clone or Append div with content  ----*/

$(document).ready(function(){
$('.adddiv').click(function(){
$(".appenddiv:first").clone(0).appendTo(".appendwrap");
});
});

           ----------( OR )-----

$(document).ready(function(){
$('.addlink').click(function(){
$(".linkvideosappend:first").clone(0).appendTo(".linkvideos");
$('.linkvideos .addlink').text('x');
  $('.linkvideos .addlink').addClass('removelink').removeClass('addlink');
$('.removelink').click(function(){  
     $(this).closest('.linkvideosappend').hide();
 });
});
});

                   ----------( OR )-----

$('.appenddivwrap .appenddiv .removelence').hide();
$(document).on('click','.addlink',function() {
$(".appenddiv:first").clone(0).appendTo($(this)).closest(".appenddivwrap");
$('.addlink .appenddiv .addlink').show();
$('.removelence').click(function(){
    $(this).closest('.appenddiv').remove();
});
});


/*---- wordpress sidebar menu show/ hide submenu with arrow----*/

$('ul.children').toggleClass("out");
  $('.page_item_has_children').addClass("fa-minus"); 
$('.page_item_has_children').click(function(e){
$(this).toggleClass("fa-plus");
$(this).children('ul.children').toggleClass("in");
$(this).siblings().children('ul.children').removeClass("in");
    e.preventDefault();
event.stopPropagation();
});

/*---- css ---*/

.fa-minus, .fa-plus { float: right; }
.fa-minus::before {content:'\f0da'; font-family:'FontAwesome';float: right;    margin:5px 8px; color: #fff; font-size:18px}
.fa-plus::before {content:'\f0d7'; font-family:'FontAwesome';float: right;    margin:5px 8px; color: #fff;font-size:18px}


/*----bootstrap sidebar menu --*/

var $myGroup = $('#sidenavwrap');
$myGroup.on('show.bs.collapse','.collapse', function() {
    $myGroup.find('.collapse.in').collapse('hide');

});

/*---- Widndow or Document auto height with resize ----*/

// set window height

$(window).load(function(){  
  var H = $( window ).height()-100;
$('.pagewrapbg').css('height', H);
});

$(window).trigger('resize');

// set window height

$(window).load(function(){
  function setHeight() {
   windowHeight = $(window).innerHeight()-80;
    $('.modelbody').css('max-height', windowHeight);
  };
  setHeight();  
  $(window).resize(function() {
    setHeight();  
  });
});

/*----  tabs show ----*/

$('#myTabs a').click(function (e) {
  e.preventDefault()
  $(this).tab('show')
})

/*---- Select field select option show/hide  ----*/

 $("select#onetimecon").change(function(){
        $(this).find("option:selected").each(function(){
            if($(this).attr("value")=="3"){              
                $("#others_onetime").show();
            }          
            else{
                $("#others_onetime").hide();
            }
        });
    }).change();

/*---- Checkbox check, uncheck  show/hide  ----*/

$("#tv_select").hide();
$('input#tv').click(function(){
  if (this.checked) {
$("#tv_select").show();

 } else {
$("#tv_select").hide();
 }
});

// attribute type

 $('input.termcond').click(function(){
  if (this.checked) {
    $("input.orderbtn").removeAttr("disabled");
$('input.orderbtn').removeClass('disabl');
  } else {
    $("input.orderbtn").attr("disabled", true);
$('input.orderbtn').addClass('disabl');
  }  
 });

/*----- Lightbox image gallery  ------*/
$('.modalbtn').click(function(){
    $('.modal-body').empty();
  var title = $(this).closest('a').attr("title");
  $('.modal-title').html(title);
  $($(this).parents('div').html()).appendTo('.modal-body');
$('.modal-body, .modal-body img').css({'text-align':'center', 'margin':'0 auto'});
  $('#PhotoModal').modal({show:true});
});

/*------ Single Page Template -------*/
$(".v_menu_link").click(function () {
    var data_id = $(this).data('id');
$(this).parent().addClass('active').siblings().removeClass('active');
 
    $('.v_menu_details').each(function() {
        var el = $(this);      
        if(el.attr('id') == data_id)
            el.show();
        else
            el.hide();

    });
});


 <div class="v_menu">
              <ul>
                <li class="active"><a href="#" class="v_menu_link" data-id="v_menu_link1"> <i class="fa fa-user"></i> About Me </a> </li>
                <li><a href="#"  class="v_menu_link" data-id="v_menu_link2"> <i class="fa fa-cogs"></i> Services</a> </li>            
              </ul>
</div>

<div class="v_menu_details initial" id="v_menu_link1">
<p> Sampl Content</p>
</div>

<style>
.v_menu_details:not(.initial) {
display: none;
}
</style>


Monday, April 4, 2016

Wordpress



/*-------------- Bread Crumb -----*/

  function the_breadcrumb() {
    global $post;
    echo '<ul id="breadcrumbs">';
    if (!is_home()) {
        echo '<li><a href="';
        echo get_option('home');
        echo '">';
        echo 'Home';
        echo '</a></li><li class="separator"> / </li>';
        if (is_category() || is_single()) {
            echo '<li>';
            the_category(' </li><li class="separator"> / </li><li> ');
            if (is_single()) {
                echo '</li><li class="separator"> / </li><li>';
                the_title();
                echo '</li>';
            }
        } elseif (is_page()) {
            if($post->post_parent){
                $anc = get_post_ancestors( $post->ID );
                $title = get_the_title();
                foreach ( $anc as $ancestor ) {
                    $output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>';
                }
                echo $output;
                echo '<strong title="'.$title.'"> '.$title.'</strong>';
            } else {
                echo '<li><strong> '.get_the_title().'</strong></li>';
            }
        }
    }
    elseif (is_tag()) {single_tag_title();}
    elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
    elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
    elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
    elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
    elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
    elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
    echo '</ul>';
}


<?php the_breadcrumb(); ?>        /* call this code in your page*/

------------------ Get content from post ID -------------

<?php  $my_postid = 219;//This is page id or post id
            $content_post = get_post($my_postid);
            $content = $content_post->post_content;
            $content = apply_filters('the_content', $content);  
?>
  <h3>
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php               
           the_title_attribute(); ?>"><?php echo get_the_title( $my_postid ); ?></a> 
</h3>

 <p><?php echo get_the_post_thumbnail( $my_postid, 'thumbnail' ); ?></p>

 <p class="postdate"> <?php echo $content; ?></p>


------------- List views Looping Code Getting from Category with Posts with content 1 ----------


 <div class="row">
    <?php $query = new WP_Query( 'cat=0,2' ); ?> 
<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>

<div class="col-lg-4 col-md-4  col-sm-4   col-xs-12 featuredbox wow fadeInDown" data-wow-duration="0.5s">
        <div class="featuredicon">  <?php the_post_thumbnail(); ?></div>
        <div class="featuredtitle"><a href="<?php echo get_permalink( $post->ID ); ?>" class="btn btn-default btn-custom single"><?php the_title(); ?></a></div>
 <p><?php echo the_content();  ?></p>
      </div>  
<!-- closes the first div box -->
<?php endwhile; 
  wp_reset_postdata();
  else : ?>
<p>
  <?php _e( 'Sorry, no posts matched your criteria.' ); ?>
</p>

<?php endif; ?>        

    </div>
------------- List views Looping Code Getting from Category with Posts with content 2  ----------

<?php $query = new WP_Query( 'cat=0,3' ); ?>

// Content limitation function(link) 
<?php 
function excerpt($limit) {
  $excerpt = explode(' ', get_the_excerpt(), $limit);
  if (count($excerpt)>=$limit) {
    array_pop($excerpt);
    $excerpt = implode(" ",$excerpt).'...';
  } else {
    $excerpt = implode(" ",$excerpt);
  }
  $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
  return $excerpt;
}

function content($limit) {
  $content = explode(' ', get_the_content(), $limit);
  if (count($content)>=$limit) {
    array_pop($content);
    $content = implode(" ",$content).'...';
  } else {
    $content = implode(" ",$content);
  }
  $content = preg_replace('/\[.+\]/','', $content);
  $content = apply_filters('the_content', $content); 
  $content = str_replace(']]>', ']]&gt;', $content);
  return $content;
}

?>


<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>

<div class="col-lg-4 col-md-4 col-sm-6 col-sm-12">

 <div class="servicebox">
   
 <h4> <a href="#" data-toggle="modal" data-target="#<?php  the_ID(); ?>"> <span  class="titletxt">   <?php the_title(); ?>   </span><span class="downloadicon"></span></a> </h4>

   <div class="serviceimg"> <a href="#" data-toggle="modal" data-target="#<?php  the_ID(); ?>">
      <?php the_post_thumbnail(); ?>
      </a> </div>

    <div class="entry servicetxt"> <a href="<?php echo get_permalink( $post->ID ); ?>" data-toggle="modal" data-target="#<?php  the_ID(); ?>"> <?php echo excerpt(80); ?></a> </div>

    <div class="servicebox_f">
      <div class="dwnld_btn"> <a href="<?php echo get_permalink( $post->ID ); ?>" data-toggle="modal" data-target="#<?php  the_ID(); ?>"> <span class="btntxt">Download the Capability Statement</span> </a> </div>
    </div>

  </div>
</div>

<!-- closes the first div box -->
<?php endwhile; 
wp_reset_postdata();
else : ?>
<p>
  <?php _e( 'Sorry, no posts matched your criteria.' ); ?>
</p>

<?php endif; ?>

/*----- Assign Category and Tags to WordPress Page [ Past in functions page] here link--------*/

function add_taxonomies_to_pages() {
 register_taxonomy_for_object_type( 'post_tag', 'page' );
 register_taxonomy_for_object_type( 'category', 'page' );
 }
add_action( 'init', 'add_taxonomies_to_pages' );

if ( ! is_admin() ) {
 add_action( 'pre_get_posts', 'category_and_tag_archives' );

 }
function category_and_tag_archives( $wp_query ) {
$my_post_array = array('post','page');

 if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) )
 $wp_query->set( 'post_type', $my_post_array );

 if ( $wp_query->get( 'tag' ) )
 $wp_query->set( 'post_type', $my_post_array );
}

------- Post list (
links)  from Category [ Past in content page]---------
  <!-- Category posts starts-->
        <?php
$related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 100, 'post__not_in' => array($post->ID) ) );
if( $related ) foreach( $related as $post ) {
setup_postdata($post); ?>
        <ul>
          <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
            <?php the_title(); ?>
            </a> </li>
        </ul>
        <?php }
wp_reset_postdata(); ?>
  <!-- Category posts end-->

------- Subcategory Post list (links) in Category ---------

    <?php
//get all child categories for category 15, then for each child category display the posts
$parent_cat = 14;
$taxonomy = 'category';
$cat_children = get_term_children( $parent_cat, $taxonomy );

if ($cat_children) { 
foreach($cat_children as $category) {
    $args=array(
      'cat' => $category,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {

echo ' <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 listboxwrap">
<div class="listbox animated fadeInUp">';

      echo "<h3>".get_cat_name( $category )."</h3>";
 

      while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
      <?php the_title(); ?>
      </a></p>
    <?php
      endwhile;

echo '</div>
</div>';

    }
  }
}
wp_reset_query();  // Restore global post data stomped by the_post().
?>

---------- Sub pages with links of Main Parent menu --------------

<?php
  global $wp_query;
  if( empty($wp_query->post->post_parent) ) {
  $parent = $wp_query->post->ID;
  } else {
  $parent = $wp_query->post->post_parent;
  } ?>
  <?php if(wp_list_pages("title_li=&child_of=$parent&echo=0" )): ?>
    <div>
    <ul class="bulletlist">
       <?php wp_list_pages("title_li=&child_of=$parent" ); ?>
    </ul>
    </div>
<?php endif; ?>



---------- Get Children of Current Page --------------

<?php
$pages = get_pages('child_of='.$post->ID.'&sort_column=post_title');
$count = 0;
foreach($pages as $page)
{ ?>

<div>  <?php echo get_the_post_thumbnail( $page->ID ); ?> </div>
<h4><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h4>
<?php
}

?>

 

---------Custom Pagination  Posts with Category -------



Reference Link for paginations click here.

<!-- Start the Loop. -->

<?php
//Protect against arbitrary paged values
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;

$args = array(
'pagination'  => true,
'posts_per_page' => 4,
'category_name' => 'your_catagory_name',
'paged' => $paged,
);

$the_query = new WP_Query( $args );   // call $the_query  variable in below loop posts
?>

<!-- Test if the current post is in category Start the Loop. -->
<?php if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<div class="wow fadeInUp">
  <!-- <div class="team-member-position"> Founder,President &amp; CEO </div>-->
  <div class="contentainer">
    <h3 class="title"> <a href="?page_id=<?php the_ID(); ?>">
      <?php the_title(); ?>
      </a> <span class="date">
      <?php the_time(get_option('date_format')); ?>
      </span> </h3>
    <div class="content"> <?php echo the_content(); ?></div>
  </div>
</div>
<?php endwhile; ?>
<?php
wp_reset_postdata();
else : ?>
<p>
  <?php _e( 'Sorry, no posts matched your criteria.' ); ?>
</p>
<?php endif; ?>

<!-- pagination numeric links here -->

<div class="pagination">

 <?php
$big = 999999999; // need an unlikely integer

echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
) );
 ?>
<!-- pagination numeric links function calling here -->
<?php echo paginate_links( $args ); ?>

</div>

Expiration  Date with post in wordpress  (link here)

<?php
  $currentdate = date("Ymd");
  $expirationdate = get_post_custom_values('expiration');   [ expiration is custom field]
  if (is_null($expirationdate)) {
  $expirestring = '30001212'; //Set future date to posts with expiry.
  } else {
  if (is_array($expirationdate)) {
  $expirestringarray = implode($expirationdate);
  }
  $expirestring = str_replace("/","",$expirestringarray);
  } //else
  if ( $expirestring > $currentdate ) { ?>
<!--end expiry code-->

<div class="newsbox">
  <?php $exp_date = get_post_meta($post->ID, 'expiration', true); ?>  
  <p>Expires On : <?php echo $exp_date; ?> </p>
  <p>Posted On : <?php echo get_the_date('Y/m/d'); ?> </p>
</div>

<?php } ?>


/*-- category template dynamically---*/

function myCategoryTemplate() { 
    if (is_category() && !is_feed()) {
        if (is_category(get_cat_id('projects')) || cat_is_ancestor_of(get_cat_id('projects'), get_query_var('cat'))) {
            load_template(TEMPLATEPATH . '/category-projects.php');
            exit;
        }
    }
}

add_action('template_redirect', 'myCategoryTemplate');

/*-- sub category template dynamically---*/

function mySubCategoryTemplate()  {
    if (is_category() && !is_feed()) {
        if (is_category(get_cat_id('projects')) || cat_is_ancestor_of(get_cat_id('projects'), get_query_var('cat'))) {
            load_template(TEMPLATEPATH . '/category-projects.php');
            exit;
        }
    }
}

add_action('template_redirect', 'mySubCategoryTemplate');


//create a custom taxonomy name it topics for your posts


function create_topics_hierarchical_taxonomy() {

// Add new taxonomy, make it hierarchical like categories
//first do the translations part for GUI

  $labels = array(
    'name' => _x( 'Chart', 'taxonomy general name' ),
    'singular_name' => _x( 'Chart', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Topics' ),
    'all_items' => __( 'All Topics' ),
    'parent_item' => __( 'Parent Topic' ),
    'parent_item_colon' => __( 'Parent Topic:' ),
    'edit_item' => __( 'Edit Topic' ), 
    'update_item' => __( 'Update Topic' ),
    'add_new_item' => __( 'Add New Topic' ),
    'new_item_name' => __( 'New Topic Name' ),
    'menu_name' => __( 'Org Chart' ),
  );

// Now register the taxonomy

  register_taxonomy('topics',array('post'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'topic' ),
  ));


}

//past in your page

<?php 
$myterms = get_terms('topics', 'orderby=none&hide_empty');    
foreach ($myterms as $term) { ?>
    <li><a href="<?php echo $term->slug; ?>"><?php echo $term->name; ?></a></li> <?php

} ?>


// past in your page ... All custom taxonomy parent, child list 


      <?php
   /** The taxonomy we want to parse */
   $taxonomy = "topics";
   /** Get all taxonomy terms */
   $terms = get_terms($taxonomy, array(
           "orderby"    => "count",
           "hide_empty" => false
       )
   );
   /** Get terms that have children */
   $hierarchy = _get_term_hierarchy($taxonomy);
       /** Loop through every term */
       foreach($terms as $term) {
       //Skip term if it has children
       if($term->parent) {
         continue;
       } 
 /** Get  more children add like this */
    if($child->parent) {
         continue;
       } 
          
   ?>   

    <ul id="org" style="display:none">
      <li><?php echo $term->name; ?>
        <ul>
          <?php   
   /** If the term has children... */
         if($hierarchy[$term->term_id]) {
       /** display them */
       foreach($hierarchy[$term->term_id] as $child) {?>
          <li>
            <?php    
   /** Get the term object by its ID */
      $child = get_term($child, "topics");
            echo $child->name; ?> 
        

         <ul>
          <?php   
   /** If the term has children... */
         if($hierarchy[$child->term_id]) {
       /** display them */
       foreach($hierarchy[$child->term_id] as $child2) {?>
          <li>
            <?php   
    /** Get the term object by its ID */
      $child2 = get_term($child2, "topics");
            echo $child2->name; ?> 
                       
          </li>
          <?php }
        }
  
   ?>
        </ul>   
        
            
          </li>
          <?php }
        }
  
   ?>
        </ul>
        </li>
    </ul>
    <?php
     }
 ?>





---------- Custom post type UI-----------------
https://www.youtube.com/watch?v=qpeTZ3ghjtY

------------Custom page templates---------------

Creating our own page in wordpres....( Like About us, Services, Contact Us)

https://www.youtube.com/watch?v=1TtN-Sz6RHc
https://www.youtube.com/watch?v=9HCxKyj1SV0


------------Create Custom Form---------------


http://www.inkthemes.com/how-you-can-easily-create-customized-form-in-wordpress/


------------ Plugins ---------------



Simple Database Export+Import+Migration
Adminer  ( formerly phpMinAdmin)All In One Php ( Executes PHP code on WordPress page)Insert PHP (inserted into WordPress posts and pages)Bootstrap 3 Shortcodes (All Bootstrap elements)Content Views( grid, scrollable list, collapsible list )Custom ScrollbarHuge IT Image Gallery (Image Gallery)Neat Slider (Home Page Slider)WonderPlugin Carousel ( nomber of rows thumbs carousel )Simple File Downloader (Download links into your posts/pages)Visual Form Builder (Dynamically build forms using a simple interface)WordPress Importer ( Import posts, pages, comments, custom fields, categories, tags etc)WP-PageNavi ( Pagination plugin )WR MegaMenu ( Megamenu )Optimus ( Optimisation images)Post Types Order ( Posts in order we can make custom)WP-Mail-SMTP  (Reconfigures the wp_mail() function to use SMTP instead of mail)Check and Enable GZIP compression ( checks if you have GZIP compression enabled )BackUpWordPress ( Simple automated backups of your WordPress powered website )Easy URL Shortcodes (EUS) ( urls, paths, and titles using shortcode for easy and consistent website links)MimeTypes Link Icons  (Adds icons automatically to any uploads and/or file links inserted into your blog posts.)Page Visit Counter  (This plugin will count the total visits of your sites pages.)W3 Total Cache(Easy Web Performance Optimization (WPO) using caching: browser, page, object, database, minify and content delivery network support.)W3 Super Cache(A very fast caching engine for WordPress that produces static html files.)Sitemap – Google XML Sitemap (for SEO)Security – DefenderEmail Integration – WP Mail SMTPSocial Integration/Sharing – Floating SocialBackup – SnapshotSEO – YoastCashing/ Image Compression – HummingbirdBlog Filter – AkismetCarousel/Featured Content – SoliloquyVideo Integration – EnviraSearch Results Enhancement – Rich Snippets