Skip to main content

Posts

Showing posts from May, 2018

FUNCTION TO GET DATE RANGE BETWEEN TWO DATES

/********************** FUNCTION TO GET DATE RANGE BETWEEN TWO DATES STARTS HERE ***************************/ function createDateRangeArray($strDateFrom,$strDateTo) {     // takes two dates formatted as YYYY-MM-DD and creates an     // inclusive array of the dates between the from and to dates.     // could test validity of dates here but I'm already doing     // that in the main script     $aryRange=array();     $iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2),     substr($strDateFrom,8,2),substr($strDateFrom,0,4));     $iDateTo=mktime(1,0,0,substr($strDateTo,5,2),     substr($strDateTo,8,2),substr($strDateTo,0,4));     if ($iDateTo>=$iDateFrom)     {         array_push($aryRange,date('Y-m-d',$iDateFrom)); // first entry         while ($iDat...

Function to add redirect url

function redirect ( $url ) { if (! headers_sent ()) { //If headers not sent yet... then do php redirect header ( 'Location: ' . $url ); exit ; } else { //If headers are sent... do javascript redirect... if javascript disabled, do html redirect. echo '<script type="text/javascript">' ; echo 'window.location.href="' . $url . '";' ; echo '</script>' ; echo '<noscript>' ; echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />' ; echo '</noscript>' ; exit ; } }   // How to use $url = "www.google.com" ; redirect ( $url );

Plugins for use

Theme my login : for login purpose Advanced custom fields : for custom field Nav Menu Roles: for show navigation according to roles Wordpress access control: for show pages according to user roles User role editor: to set permissions according to user roles Redirect after login: to redirect after login according to user roles Flamingo : for saving contact form 7 forms to database Tabs portfolio - filterable portfolio plugin free Remove Dashboard Access

Pagination with custom loop

<? php //get the current page $paged = ( get_query_var ( 'paged' )) ? get_query_var ( 'paged' ) : 1 ; //pagination fixes prior to loop $temp = $query ; $query = null ; //custom loop using WP_Query $query = new WP_Query ( array ( 'post_status' => 'publish' , 'orderby' => 'date' , 'order' => 'ASC' ) ); //set our query's pagination to $paged $query -> query ( 'post_type=post&posts_per_page=5' . '&paged=' . $paged ); if ( $query -> have_posts () ) : while ( $query -> have_posts () ) : $query -> the_post (); ?> <li> <? php if ( has_post_thumbnail ()) : ?> <? php the_post_thumbnail ();?> <? php endif ; ?> <div class = "someclass" > <h2> <? php the_title (); ?> </h2...