Skip to main content

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url,

Wordpress


Note
For include connection

include_once('../../../wp-config.php');
include_once('../../../wp-load.php');
include_once('../../../wp-includes/wp-db.php');
=================
Get role in wordpress
<?php
//list each role and each user with that role (works if logged in)
//see http://wordpress.org/support/topic/256436 if not logged in:
global $wp_roles;
foreach( $wp_roles->role_names as $role => $name ) {
  $name = translate_with_context($name);
  $this_role = "'[[:<:]]".$role."[[:>:]]'";
  $query = "SELECT * FROM $wpdb->users WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value RLIKE $this_role) ORDER BY user_nicename ASC LIMIT 10000";
  $users_of_this_role = $wpdb->get_results($query);
  if ($users_of_this_role) {
    foreach($users_of_this_role as $user) {
      $curuser = get_userdata($user->ID);
      $author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename);
if($curuser->user_login==$submit_info->user_login)
{
echo "Role Is:". $name;
}

     // echo '<p>--User nicename: '.$curuser->user_login .', display Name: '. $curuser->display_name . ', link to author posts <a href="' . $author_post_url . '" title="' . sprintf( __( "Posts by %s" ), $curuser->user_nicename ) . '" ' . '>' . $curuser->user_nicename .'</a></p>';
    }
  }
}
?>
========================
// Create short code in wordpress
//[samrat id="1" name="Samrat Kehari Parida"]
function samratfun( $atts ) {
    extract( shortcode_atts( array(
        'id' => '1',
        'name' => 'Samrat',
    ), $atts ) );
    return "Your Id is ".$id ." and Name is ".$name;
}
add_shortcode( 'samrat', 'samratfun' );
===============
/*Remove empty paragraph tags from the_content*/
add_filter( 'the_content', 'remove_empty_p', 20, 1 );
function remove_empty_p( $content ){
// clean up p tags around block elements
$content = preg_replace( array(
'#<p>\s*<(div|aside|section|article|header|footer)#',
'#</(div|aside|section|article|header|footer)>\s*</p>#',
'#</(div|aside|section|article|header|footer)>\s*<br ?/?>#',
'#<(div|aside|section|article|header|footer)(.*?)>\s*</p>#',
'#<p>\s*</(div|aside|section|article|header|footer)#',
), array(
'<$1',
'</$1>',
'</$1>',
'<$1$2>',
'</$1',
), $content );

return preg_replace('#<p>(\s|&nbsp;)*+(<br\s*/*>)*(\s|&nbsp;)*</p>#i', '', $content);
}

==============
Blog page all condition
if( is_category() || is_tag() || is_author() || is_date() || is_search() || is_archive() ) {
----------------------
Add page in wordpress ex: loop-header.php

<?php get_template_part( 'loop-header' ); ?>
---------

<?php echo substr(get_the_excerpt(), 0,30); ?>

<a href="#contact_form_pop" class="fancybox">Contact Us</a>

<div style="display:none" class="fancybox-hidden">
    <div id="contact_form_pop">

    </div>
</div>
-------------
.htaccess

Redirect 301 /contact.php http://yourrighthand.co.uk/contact/

//ad menu
in function.php
add_action( 'init', 'my_custom_menus' );
function my_custom_menus() {
    register_nav_menus(
        array(
            'primary-menu2' => __( 'Primary Menu2' ),
            'primary-menu3' => __( 'primary-menu3' ),
            'primary-menu4' => __( 'primary-menu4' )
        )
    );
}
----------------
/* hide admin bar*/

/**
 * Disable admin bar on the frontend of your website
 * for subscribers.
 */
function themeblvd_disable_admin_bar() {
if( ! current_user_can('edit_posts') )
add_filter('show_admin_bar', '__return_false');
}
add_action( 'after_setup_theme', 'themeblvd_disable_admin_bar' );

/**
 * Redirect back to homepage and not allow access to
 * WP admin for Subscribers.
 */
function themeblvd_redirect_admin(){
if ( ! current_user_can( 'edit_posts' ) ){
wp_redirect( site_url() );
exit;
}
}
add_action( 'admin_init', 'themeblvd_redirect_admin' );

---------------------------------------------

//banner
 <div class="banner">
    <div id="wowslider-container1" class="slide">
            <div class="ws_images">
                <ul>
                <?php query_posts('cat=4');
while (have_posts()) : the_post(); ?>    
       <li>
                    <?php echo the_post_thumbnail($page->ID); ?>
                        <div class="slide-cnt">
                       <?php the_content();?>
                        </div>
                    </li>
                <?php endwhile; ?>
                </ul>
            </div>
            <div class="ws_bullets slide-control">
                <div>
                <?php while(have_posts()) : the_post();?> <a href="#"></a><?php endwhile;?>
                    <?php wp_reset_query(); ?>
                </div>
            </div>
        </div>  
<script type="text/javascript" src="<?php echo get_bloginfo('template_url') ?>/js/wowslider.js"></script>
        <script type="text/javascript" src="<?php echo get_bloginfo('template_url') ?>/js/script.js"></script>
    </div>

===========




WordPress : Category wise post display
Posted on September 6, 2012 by Ajit Kumar Singh

<?php // get all the categories from the database
$cats = get_categories();
// loop through the categries
foreach ($cats as $cat) {
// setup the cateogory ID
$cat_id= $cat->term_id;
// Make a header for the cateogry
echo “<h2>”.$cat->name.”</h2>”;
// create a custom wordpress query
query_posts(“cat=$cat_id&post_per_page=100?);

if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php // create our link now that the post is setup ?>

<a href=”<?php the_permalink();?>”><?php the_title(); ?></a>

<?php echo ‘<hr/>’; ?>

<?php endwhile; endif;
// done our wordpress loop. Will start again for each category ?>

<?php } // done the foreach statement ?>

//add contact us redirection page
add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
function wpcf7_custom_form_action_url()
{
    return 'http://yomptesting.com/influence/thank-you-page/';
}

 <?php echo get_the_title($ID); ?> get page name
//get post message in db
<?php
$args = array(
'post_type' => 'testimonial',
'tax_query' => array(
array(
'taxonomy' => 'testimonial-category',
'field' => 'term_id',
'terms' => 4
)
)
);
 $loop = new WP_Query( $args ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_post_thumbnail(); ?>          
<?php the_content() ?>
<?php endwhile; ?>

//get the home page post id in php page in wordpress


<div class="getPages"> <?php
  $home_page_post_id = 674;
  $home_page_post = get_post( $home_page_post_id, ARRAY_A );
  $content_home = $home_page_post['post_content'];
  echo $content_home; ?> </div>
  <p><?php echo trim(substr(strip_tags($content_home),0,500));?></p>



  //contact us
  [email-download download_id="225" contact_form_id="178" title="Contact form 1"]

  <?php if(is_page('home')){?>

  <div class="homeblock2">

    <div class="blk fltL">

      <h1>PERSONAL TRAINING</h1>

      <?php

                            $home_page_post_id = 430;

                            $home_page_post = get_post( $home_page_post_id, ARRAY_A );

                            $content_home = $home_page_post['post_content'];  

                            //echo $small = substr($content_home, 0, 100);

                           ?><p><?php echo trim(substr(strip_tags($content_home),0,500));?></p><?php

                            //echo $content_home;?>

      <a class="read-more" href="http://www.yomptesting.com/fullcirclefitness/personal-training/"><img src="<?PHP echo bloginfo("template_url"); ?>/images/read-more-btn.png" /></a><span class="block-pro"><img src="<?PHP echo bloginfo("template_url"); ?>/images/block-pro.png"  /></span>

   

    </div>

//in function.php add Widgets

register_sidebar( array(
'name' => __( 'Home Page Maintenance', 'twentytwelve' ),
'id' => 'maintanance',
'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );

///add wordpress menu description
in function.php file add this


add_filter('walker_nav_menu_start_el', 'description_in_nav_el', 10, 4);
function description_in_nav_el($item_output, $item, $depth, $args)
{
return preg_replace('/(<a.*?>[^<]*?)</', '$1' . "<em>{$item->attr_title}</em><", $item_output);
}

function themeteam_page (){
global $options, $themename, $manualurl;


///bloginfo url

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


//WYSIWYG Widgets
[pagelist sort_column="menu_order" exclude="321,322,323,364,395,316,406,407,408,409"]
in php
<?php dynamic_sidebar('sitemap sidebar'); ?>


//gst template url
<?php echo get_template_directory_uri(); ?>

//get page id
<?php echo get_the_ID(); ?>


/* Custom Archives Functions   */
<div id="content" role="main">

<?php the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>

<?php get_search_form(); ?>

<h2>Archives by Month:</h2>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>
<h2>Archives by Yearly:</h2>
<ul>
<?php wp_get_archives('type=yearly'); ?>
</ul>
<h2>Archives by Subject:</h2>
<ul>
<?php wp_list_categories(); ?>
</ul>

</div><!-- #content -->


//nos of category count

<?php
$num_cats  = wp_count_terms('category');
$num_parent_cats=count(get_categories('parent=0&hide_empty=0'));
$num_child_cats = $num_cats-$num_parent_cats;

echo '<p>number of categories: ' . $num_cats . '</p>';
echo '<p>number of child categories: ' . $num_child_cats . '</p>';

?>
site:http://codex.wordpress.org/Template_Tags/wp_list_categories ( plugin: Compact Archives)
//nos of category count product
<?php
$select = wp_list_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');
echo $select;
?>
//dropdown category
 <?php wp_dropdown_categories( $args ); ?>


 //dropdown submit category
 <li id="categories"><h2><?php _e('Posts by Category'); ?></h2>
<?php wp_dropdown_categories('show_option_none=Select category'); ?>

<script type="text/javascript"><!--
    var dropdown = document.getElementById("cat");
    function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option('home');
?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
}
    }
    dropdown.onchange = onCatChange;
--></script>
</li>
//dropdown count category product

<li id="categories">
<h2><?php _e('Posts by Category'); ?></h2>
<form action="<?php bloginfo('url'); ?>/" method="get">
<div>
<?php
$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
?>
<noscript><div><input type="submit" value="View" /></div></noscript>
</div></form>
</li>

//add widget
<?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-2' ); ?>
</div>
<?php endif; ?>


///read more link in post

required plugin (read more link) and code in blog .php

<h1 class="pageTitle">News Blog</h1>

<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('posts_per_page=3'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>

<?php get_template_part( 'content', get_post_format() ); ?>

<?php endwhile; ?>


                 <?php if (function_exists("pagination")) {
pagination($additional_loop->max_num_pages);
   } ?>
<?php $wp_query = null; $wp_query = $temp;?>

put in function.php
/*--------------------------------pagination starts here---------------------------*/

function pagination($pages = '', $range = 2)
{
$showitems = ($range * 2)+1;

global $paged;
if(empty($paged)) $paged = 1;

if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}

if(1 != $pages)
{
echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo; First</a>";
if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo; Previous</a>";

for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
}
}

if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next &rsaquo;</a>";
if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last &raquo;</a>";
echo "</div>\n";
}
}

/*--------------------------------------------------------------ends here------------------------*/

css put in css

/*--------------------------------------blog--pagination-------------------------------*/

.pagination {
clear:both;
padding:20px 0;
position:relative;
font-size:11px;
line-height:13px;
}

.pagination span, .pagination a {
display:block;
float:left;
margin: 2px 2px 2px 0;
padding:6px 9px 5px 9px;
text-decoration:none;
width:auto;
color:#fff;
background: #555;
}

.pagination a:hover{
color:#fff;
background: #3279BB;
}

.pagination .current{
padding:6px 9px 5px 9px;
background: #3279BB;
color:#fff;
}

/*---------------------------style pagination end----------------------------*/



//display all post page
<?php wp_get_archives('type=alpha'); ?>


Show Blog Title
Displays your blog's title in a <h1> tag.
 <h1><?php echo get_option( 'blogname' ); ?></h1>

Show Character Set
Displays the character set your blog is using (ex: UTF-8)
 <p>Character set: <?php echo get_option( 'blog_charset' ); ?> </p>

Retrieve Administrator E-mail
Retrieve the e-mail of the blog administrator, storing it in a variable.
 <?php $admin_email = get_option( 'admin_email' ); ?>



 -------------------------------------------------------------------------
 List of Short Codes for NextGEN Gallery

Short codes are the piece of text which you add along with you text on your blog post or sidebars. Short codes can also be added inside the theme templates.

For a slideshow :[ slideshow id=x w=width h=height ]
For a album : [ album id=x template=extend] or [ album id=x template=compact ]
For a gallery : [  nggallery id=x ]
For a single picture : [ singlepic id=x w=width h=height mode=web20|watermark float=left|right ]
For a image browser : [ imagebrowse r id=x ]
To show image sorted by tags :[ nggtags gallery=mytag,wordpress,...  ]
To show tag albums : [ nggtags album=mytag,wordpress,...  ]

--------------------------------------------------
//read more..
function new_excerpt_more( $more ) {
return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">Read More</a>';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
===========================================
///blog  category show
<?php $args = array( 'post_type' => 'post',  'posts_per_page' => 2, 'orderby' => desc );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<h2 class="member-name"><?php the_title(); ?></h2>
    <div class="member-description">
<?php the_post_thumbnail('thumbnail');?>
<?php the_content(); ?>
    </div>
<?php endwhile; ?>
------------------
///specific category table wp_terms
<?php
$catquery = new WP_Query( 'cat=4&posts_per_page=2' );
while($catquery->have_posts()) : $catquery->the_post();
?>
<ul>
<li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>

<ul><li><?php the_content(); ?></li>
</ul>
</li>
</ul>
<?php endwhile; ?>
------------------------

is_page( array( 42, 'about-me', 'About Me And Joe' ) )

include file
ex.php
<?php get_template_part( 'ex'); ?>


//include file in admin page
<?php  include ("/wp-content/themes/yourrighthand/home_slider.php"); ?>
<?php echo get_site_url(); ?>
//include file in php page

<?php   include (TEMPLATEPATH .'/footer_slider.php');  ?>

<?php
$args = array('order' =>'DESC', 'post_type' => 'testimonial', 'posts_per_page' => 2);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<h2>';the_date();
echo '</h2>';

echo '<p>';
$content = get_the_content();
$content = strip_tags($content);
echo substr($content ,0,250);

echo '<p>';

endwhile;?>

//photo crop
add_image_size( 'homepage-thumb', 80, 90);


------------------------------------
//hide the admin bar for subscribers
/**
 * Disable admin bar on the frontend of your website
 * for subscribers.
 */
function themeblvd_disable_admin_bar() {
if( ! current_user_can('edit_posts') )
add_filter('show_admin_bar', '__return_false');
}
add_action( 'after_setup_theme', 'themeblvd_disable_admin_bar' );

/**
 * Redirect back to homepage and not allow access to
 * WP admin for Subscribers.
 */
function themeblvd_redirect_admin(){
if ( ! current_user_can( 'edit_posts' ) ){
wp_redirect( site_url() );
exit;
}
}
add_action( 'admin_init', 'themeblvd_redirect_admin' );


------------------

Login Form custom

Add in header.php
<?php

 if(!is_user_logged_in()){
   get_template_part('login');
 }

?>

add in page .php

<?php
if ( is_user_logged_in() ) { ?>
<a href="<?php echo wp_logout_url( home_url() ); ?>" title="Logout">Logout</a>
<?php
} else {
?>

<?php } ?>

<form action="" method="post">
  <div>
    User name: <input name="log" type="text" />
  </div>
  <div>
    Password: <input name="pwd" type="password" />
  </div>
  <div>
  <input id="rememberme" type="checkbox" value="forever" name="rememberme">
  <input type="hidden" value="1" name="testcookie">eqwew
    <input type="submit" value="Login" />
    <input type="hidden" name="action" value="my_login_action" />
  </div>
</form>

add in function.php

add_action('init', function(){

  // not the login request?
  if(!isset($_POST['action']) || $_POST['action'] !== 'my_login_action')
    return;

  // see the codex for wp_signon()
  $result = wp_signon();

  if(is_wp_error($result))
    wp_die('Login failed. Wrong password or user name?');

  // redirect back to the requested page if login was successful  
  header('Location: ' . $_SERVER['REQUEST_URI']);
  exit;
});

======================================

//feature image
add_theme_support('post-thumbnails');
add_image_size('featured_preview', 55, 55, true);
// GET FEATURED IMAGE
function ST4_get_featured_image($post_ID) {
    $post_thumbnail_id = get_post_thumbnail_id($post_ID);
    if ($post_thumbnail_id) {
        $post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'featured_preview');
        return $post_thumbnail_img[0];
    }
}
// ADD NEW COLUMN
function ST4_columns_head($defaults) {
    $defaults['featured_image'] = 'Featured Image';
    return $defaults;
}

// SHOW THE FEATURED IMAGE
function ST4_columns_content($column_name, $post_ID) {
    if ($column_name == 'featured_image') {
        $post_featured_image = ST4_get_featured_image($post_ID);
        if ($post_featured_image) {
            echo '<img src="' . $post_featured_image . '" />';
        }
    }
}
add_filter('manage_posts_columns', 'ST4_columns_head');
add_action('manage_posts_custom_column', 'ST4_columns_content', 10, 2);


-------------------


//add post type to custom category

register_post_type('people',
array( 'label' => 'People',
'public' => true,'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => ''),
'query_var' => true,
'has_archive' => true,
'supports' => array('title','editor','thumbnail',),
'taxonomies' => array('category',),
'menu_position' => 15,
) );


add_action('init', 'register_mypost_type');
function register_mypost_type()
{
register_post_type('people',array('label' => 'People','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => ''),'query_var' => true,'has_archive' => true,'supports' => array('title','editor','thumbnail',),'taxonomies' => array('category',),'menu_position' => 5,) );}

<?php
/**
 * Twenty Fourteen functions and definitions
 *
 * Set up the theme and provides some helper functions, which are used in the
 * theme as custom template tags. Others are attached to action and filter
 * hooks in WordPress to change core functionality.
 *
 * When using a child theme you can override certain functions (those wrapped
 * in a function_exists() call) by defining them first in your child theme's
 * functions.php file. The child theme's functions.php file is included before
 * the parent theme's file, so the child theme functions would be used.
 *
 * @link http://codex.wordpress.org/Theme_Development
 * @link http://codex.wordpress.org/Child_Themes
 *
 * Functions that are not pluggable (not wrapped in function_exists()) are
 * instead attached to a filter or action hook.
 *
 * For more information on hooks, actions, and filters,
 * @link http://codex.wordpress.org/Plugin_API
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */
/**
 * Set up the content width value based on the theme's design.
 *
 * @see twentyfourteen_content_width()
 *
 * @since Twenty Fourteen 1.0
 */
global $private_table;
if (!isset($content_width)) {
    $content_width = 474;
}
add_filter('widget_text', 'do_shortcode');
/**
 * Twenty Fourteen only works in WordPress 3.6 or later.
 */
if (version_compare($GLOBALS['wp_version'], '3.6', '<')) {
    require get_template_directory() . '/inc/back-compat.php';
}

if (!function_exists('twentyfourteen_setup')) :

    /**
     * Twenty Fourteen setup.
     *
     * Set up theme defaults and registers support for various WordPress features.
     *
     * Note that this function is hooked into the after_setup_theme hook, which
     * runs before the init hook. The init hook is too late for some features, such
     * as indicating support post thumbnails.
     *
     * @since Twenty Fourteen 1.0
     */
    function twentyfourteen_setup() {

        /*
         * Make Twenty Fourteen available for translation.
         *
         * Translations can be added to the /languages/ directory.
         * If you're building a theme based on Twenty Fourteen, use a find and
         * replace to change 'twentyfourteen' to the name of your theme in all
         * template files.
         */
        load_theme_textdomain('twentyfourteen', get_template_directory() . '/languages');

        // This theme styles the visual editor to resemble the theme style.
        add_editor_style(array('css/editor-style.css', twentyfourteen_font_url()));

        // Add RSS feed links to <head> for posts and comments.
        add_theme_support('automatic-feed-links');

        // Enable support for Post Thumbnails, and declare two sizes.
        add_theme_support('post-thumbnails');
        set_post_thumbnail_size(672, 372, true);
        add_image_size('twentyfourteen-full-width', 1038, 576, true);

        // This theme uses wp_nav_menu() in two locations.
        register_nav_menus(array(
            'primary' => __('Top primary menu', 'twentyfourteen'),
            'secondary' => __('Secondary menu in left sidebar', 'twentyfourteen'),
        ));

        /*
         * Switch default core markup for search form, comment form, and comments
         * to output valid HTML5.
         */
        add_theme_support('html5', array(
            'search-form', 'comment-form', 'comment-list',
        ));

        /*
         * Enable support for Post Formats.
         * See http://codex.wordpress.org/Post_Formats
         */
        add_theme_support('post-formats', array(
            'aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery',
        ));

        // This theme allows users to set a custom background.
        add_theme_support('custom-background', apply_filters('twentyfourteen_custom_background_args', array(
                    'default-color' => 'f5f5f5',
                )));

        // Add support for featured content.
        add_theme_support('featured-content', array(
            'featured_content_filter' => 'twentyfourteen_get_featured_posts',
            'max_posts' => 6,
        ));

        // This theme uses its own gallery styles.
        add_filter('use_default_gallery_style', '__return_false');
    }

endif; // twentyfourteen_setup
add_action('after_setup_theme', 'twentyfourteen_setup');

/**
 * Adjust content_width value for image attachment template.
 *
 * @since Twenty Fourteen 1.0
 *
 * @return void
 */
function twentyfourteen_content_width() {
    if (is_attachment() && wp_attachment_is_image()) {
        $GLOBALS['content_width'] = 810;
    }
}

add_action('template_redirect', 'twentyfourteen_content_width');

/**
 * Getter function for Featured Content Plugin.
 *
 * @since Twenty Fourteen 1.0
 *
 * @return array An array of WP_Post objects.
 */
function twentyfourteen_get_featured_posts() {
    /**
     * Filter the featured posts to return in Twenty Fourteen.
     *
     * @since Twenty Fourteen 1.0
     *
     * @param array|bool $posts Array of featured posts, otherwise false.
     */
    return apply_filters('twentyfourteen_get_featured_posts', array());
}

/**
 * A helper conditional function that returns a boolean value.
 *
 * @since Twenty Fourteen 1.0
 *
 * @return bool Whether there are featured posts.
 */
function twentyfourteen_has_featured_posts() {
    return!is_paged() && (bool) twentyfourteen_get_featured_posts();
}

/**
 * Register three Twenty Fourteen widget areas.
 *
 * @since Twenty Fourteen 1.0
 *
 * @return void
 */
function twentyfourteen_widgets_init() {
    require get_template_directory() . '/inc/widgets.php';
    register_widget('Twenty_Fourteen_Ephemera_Widget');

    register_sidebar(array(
        'name' => __('Primary Sidebar', 'twentyfourteen'),
        'id' => 'sidebar-1',
        'description' => __('Main sidebar that appears on the left.', 'twentyfourteen'),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h1 class="widget-title">',
        'after_title' => '</h1>',
    ));
    register_sidebar(array(
        'name' => __('Content Sidebar', 'twentyfourteen'),
        'id' => 'sidebar-2',
        'description' => __('Additional sidebar that appears on the right.', 'twentyfourteen'),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h1 class="widget-title">',
        'after_title' => '</h1>',
    ));
    register_sidebar(array(
        'name' => __('Footer Widget Area', 'twentyfourteen'),
        'id' => 'sidebar-3',
        'description' => __('Appears in the footer section of the site.', 'twentyfourteen'),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h1 class="widget-title">',
        'after_title' => '</h1>',
    ));
    register_sidebar(array(
        'name' => __('Home Sidebar', 'twentyfourteen'),
        'id' => 'home-sidebar',
        'description' => __('Appears in the home page of the site.', 'twentyfourteen'),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h1 class="widget-title">',
        'after_title' => '</h1>',
    ));
    register_sidebar(array(
        'name' => __('Signed Home Sidebar', 'twentyfourteen'),
        'id' => 'home-signed-sidebar',
        'description' => __('Appears in the home page of the site when the user is sign in.', 'twentyfourteen'),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h1 class="widget-title">',
        'after_title' => '</h1>',
    ));
    register_sidebar(array(
        'name' => __('class Sidebar', 'twentyfourteen'),
        'id' => 'class-sidebar',
        'description' => __('Appears in the classes page of the site.', 'twentyfourteen'),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h1 class="widget-title">',
        'after_title' => '</h1>',
    ));
    register_sidebar(array(
        'name' => __('Sample class Sidebar', 'twentyfourteen'),
        'id' => 'sample-class-sidebar',
        'description' => __('Appears in the Sample class page of the site.', 'twentyfourteen'),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h1 class="widget-title">',
        'after_title' => '</h1>',
    ));
}

add_action('widgets_init', 'twentyfourteen_widgets_init');

/**
 * Register Lato Google font for Twenty Fourteen.
 *
 * @since Twenty Fourteen 1.0
 *
 * @return string
 */
function twentyfourteen_font_url() {
    $font_url = '';
    /*
     * Translators: If there are characters in your language that are not supported
     * by Lato, translate this to 'off'. Do not translate into your own language.
     */
    if ('off' !== _x('on', 'Lato font: on or off', 'twentyfourteen')) {
        $font_url = add_query_arg('family', urlencode('Lato:300,400,700,900,300italic,400italic,700italic'), "//fonts.googleapis.com/css");
    }

    return $font_url;
}

/**
 * Enqueue scripts and styles for the front end.
 *
 * @since Twenty Fourteen 1.0
 *
 * @return void
 */
function twentyfourteen_scripts() {
    // Add Lato font, used in the main stylesheet.
    wp_enqueue_style('twentyfourteen-lato', twentyfourteen_font_url(), array(), null);

    // Add Genericons font, used in the main stylesheet.
    wp_enqueue_style('genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.0.2');

    // Load our main stylesheet.
    wp_enqueue_style('twentyfourteen-style', get_stylesheet_uri(), array('genericons'));

    // Load the Internet Explorer specific stylesheet.
    wp_enqueue_style('twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array('twentyfourteen-style', 'genericons'), '20131205');
    wp_style_add_data('twentyfourteen-ie', 'conditional', 'lt IE 9');

    if (is_singular() && comments_open() && get_option('thread_comments')) {
        wp_enqueue_script('comment-reply');
    }

    if (is_singular() && wp_attachment_is_image()) {
        wp_enqueue_script('twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array('jquery'), '20130402');
    }

    if (is_active_sidebar('sidebar-3')) {
        wp_enqueue_script('jquery-masonry');
    }

    if (is_front_page() && 'slider' == get_theme_mod('featured_content_layout')) {
        wp_enqueue_script('twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array('jquery'), '20131205', true);
        wp_localize_script('twentyfourteen-slider', 'featuredSliderDefaults', array(
            'prevText' => __('Previous', 'twentyfourteen'),
            'nextText' => __('Next', 'twentyfourteen')
        ));
    }

    wp_enqueue_script('twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array('jquery'), '20131209', true);
}

add_action('wp_enqueue_scripts', 'twentyfourteen_scripts');

/**
 * Enqueue Google fonts style to admin screen for custom header display.
 *
 * @since Twenty Fourteen 1.0
 *
 * @return void
 */
function twentyfourteen_admin_fonts() {
    wp_enqueue_style('twentyfourteen-lato', twentyfourteen_font_url(), array(), null);
}

add_action('admin_print_scripts-appearance_page_custom-header', 'twentyfourteen_admin_fonts');

if (!function_exists('twentyfourteen_the_attached_image')) :

    /**
     * Print the attached image with a link to the next attached image.
     *
     * @since Twenty Fourteen 1.0
     *
     * @return void
     */
    function twentyfourteen_the_attached_image() {
        $post = get_post();
        /**
         * Filter the default Twenty Fourteen attachment size.
         *
         * @since Twenty Fourteen 1.0
         *
         * @param array $dimensions {
         *     An array of height and width dimensions.
         *
         *     @type int $height Height of the image in pixels. Default 810.
         *     @type int $width  Width of the image in pixels. Default 810.
         * }
         */
        $attachment_size = apply_filters('twentyfourteen_attachment_size', array(810, 810));
        $next_attachment_url = wp_get_attachment_url();

        /*
         * Grab the IDs of all the image attachments in a gallery so we can get the URL
         * of the next adjacent image in a gallery, or the first image (if we're
         * looking at the last image in a gallery), or, in a gallery of one, just the
         * link to that image file.
         */
        $attachment_ids = get_posts(array(
                    'post_parent' => $post->post_parent,
                    'fields' => 'ids',
                    'numberposts' => -1,
                    'post_status' => 'inherit',
                    'post_type' => 'attachment',
                    'post_mime_type' => 'image',
                    'order' => 'ASC',
                    'orderby' => 'menu_order ID',
                ));

        // If there is more than 1 attachment in a gallery...
        if (count($attachment_ids) > 1) {
            foreach ($attachment_ids as $attachment_id) {
                if ($attachment_id == $post->ID) {
                    $next_id = current($attachment_ids);
                    break;
                }
            }

            // get the URL of the next image attachment...
            if ($next_id) {
                $next_attachment_url = get_attachment_link($next_id);
            }

            // or get the URL of the first image attachment.
            else {
                $next_attachment_url = get_attachment_link(array_shift($attachment_ids));
            }
        }

        printf('<a href="%1$s" rel="attachment">%2$s</a>',
                esc_url($next_attachment_url),
                wp_get_attachment_image($post->ID, $attachment_size)
        );
    }

endif;

if (!function_exists('twentyfourteen_list_authors')) :

    /**
     * Print a list of all site contributors who published at least one post.
     *
     * @since Twenty Fourteen 1.0
     *
     * @return void
     */
    function twentyfourteen_list_authors() {
        $contributor_ids = get_users(array(
                    'fields' => 'ID',
                    'orderby' => 'post_count',
                    'order' => 'DESC',
                    'who' => 'authors',
                ));

        foreach ($contributor_ids as $contributor_id) :
            $post_count = count_user_posts($contributor_id);

            // Move on if user has not published a post (yet).
            if (!$post_count) {
                continue;
            }
?>

            <div class="contributor">
                <div class="contributor-info">
                    <div class="contributor-avatar"><?php echo get_avatar($contributor_id, 132); ?></div>
                    <div class="contributor-summary">
                        <h2 class="contributor-name"><?php echo get_the_author_meta('display_name', $contributor_id); ?></h2>
                        <p class="contributor-bio">
                <?php echo get_the_author_meta('description', $contributor_id); ?>
            </p>
            <a class="contributor-posts-link" href="<?php echo esc_url(get_author_posts_url($contributor_id)); ?>">
                <?php printf(_n('%d Article', '%d Articles', $post_count, 'twentyfourteen'), $post_count); ?>
            </a>
        </div><!-- .contributor-summary -->
    </div><!-- .contributor-info -->
</div><!-- .contributor -->

<?php
                endforeach;
            }

        endif;

        /**
         * Extend the default WordPress body classes.
         *
         * Adds body classes to denote:
         * 1. Single or multiple authors.
         * 2. Presence of header image.
         * 3. Index views.
         * 4. Full-width content layout.
         * 5. Presence of footer widgets.
         * 6. Single views.
         * 7. Featured content layout.
         *
         * @since Twenty Fourteen 1.0
         *
         * @param array $classes A list of existing body class values.
         * @return array The filtered body class list.
         */
        function twentyfourteen_body_classes($classes) {
            if (is_multi_author ()) {
                $classes[] = 'group-blog';
            }

            if (get_header_image ()) {
                $classes[] = 'header-image';
            } else {
                $classes[] = 'masthead-fixed';
            }

            if (is_archive() || is_search() || is_home()) {
                $classes[] = 'list-view';
            }

            if ((!is_active_sidebar('sidebar-2') )
                    || is_page_template('page-templates/full-width.php')
                    || is_page_template('page-templates/contributors.php')
                    || is_attachment()) {
                $classes[] = 'full-width';
            }

            if (is_active_sidebar('sidebar-3')) {
                $classes[] = 'footer-widgets';
            }

            if (is_singular() && !is_front_page()) {
                $classes[] = 'singular';
            }

            if (is_front_page() && 'slider' == get_theme_mod('featured_content_layout')) {
                $classes[] = 'slider';
            } elseif (is_front_page ()) {
                $classes[] = 'grid';
            }

            return $classes;
        }

        add_filter('body_class', 'twentyfourteen_body_classes');

        /**
         * Extend the default WordPress post classes.
         *
         * Adds a post class to denote:
         * Non-password protected page with a post thumbnail.
         *
         * @since Twenty Fourteen 1.0
         *
         * @param array $classes A list of existing post class values.
         * @return array The filtered post class list.
         */
        function twentyfourteen_post_classes($classes) {
            if (!post_password_required() && has_post_thumbnail()) {
                $classes[] = 'has-post-thumbnail';
            }

            return $classes;
        }

        add_filter('post_class', 'twentyfourteen_post_classes');

        /**
         * Create a nicely formatted and more specific title element text for output
         * in head of document, based on current view.
         *
         * @since Twenty Fourteen 1.0
         *
         * @param string $title Default title text for current view.
         * @param string $sep Optional separator.
         * @return string The filtered title.
         */
        function twentyfourteen_wp_title($title, $sep) {
            global $paged, $page;

            if (is_feed ()) {
                return $title;
            }

            // Add the site name.
            $title .= get_bloginfo('name');

            // Add the site description for the home/front page.
            $site_description = get_bloginfo('description', 'display');
            if ($site_description && ( is_home() || is_front_page() )) {
                $title = "$title $sep $site_description";
            }

            // Add a page number if necessary.
            if ($paged >= 2 || $page >= 2) {
                $title = "$title $sep " . sprintf(__('Page %s', 'twentyfourteen'), max($paged, $page));
            }

            return $title;
        }

        add_filter('wp_title', 'twentyfourteen_wp_title', 10, 2);

// Implement Custom Header features.
        require get_template_directory() . '/inc/custom-header.php';

// Custom template tags for this theme.
        require get_template_directory() . '/inc/template-tags.php';

// Add Theme Customizer functionality.
        require get_template_directory() . '/inc/customizer.php';

        /*
         * Add Featured Content functionality.
         *
         * To overwrite in a plugin, define your own Featured_Content class on or
         * before the 'setup_theme' hook.
         */
        if (!class_exists('Featured_Content') && 'plugins.php' !== $GLOBALS['pagenow']) {
            require get_template_directory() . '/inc/featured-content.php';
        }

        /*         * *****************************************************************************************
         * function for registering post type
         * ***************************************************************************************** */
        add_action('init', 'ed_post_type_init');

        function ed_post_type_init() {

            $labels = array(
                'name' => _('Testimonial'),
                'singular_name' => _('Testimonial'),
                'add_new' => _('Add New Testimonial'),
                'add_new_item' => _('Add New Testimonial'),
                'edit_item' => _('Edit Testimonial'),
                'new_item' => _('New Testimonial'),
                'view_item' => _('View Testimonial'),
                'search_items' => _('Search Testimonial'),
                'not_found' => _('Nothing found'),
                'not_found_in_trash' => _('Nothing found in Trash'),
            );

            $args = array(
                'labels' => $labels,
                'public' => true,
                'publicly_queryable' => true,
                'show_ui' => true,
                'query_var' => true,
                'rewrite' => true,
                'capability_type' => 'post',
                'hierarchical' => false,
                'menu_position' => 20,
                'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
            );

            register_post_type('Testimonial', $args);

            $labels2 = array(
                'name' => _('Courses'),
                'singular_name' => _('Courses'),
                'add_new' => _('Add New Course'),
                'add_new_item' => _('Add New Course'),
                'edit_item' => _('Edit Course'),
                'new_item' => _('New Course'),
                'view_item' => _('View Course'),
                'search_items' => _('Search Course'),
                'not_found' => _('Nothing found'),
                'not_found_in_trash' => _('Nothing found in Trash'),
            );

            $args2 = array(
                'labels' => $labels2,
                'public' => true,
                'publicly_queryable' => true,
                'show_ui' => true,
                'query_var' => true,
                'rewrite' => true,
                'capability_type' => 'post',
                'hierarchical' => false,
                'menu_position' => 20,
                'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
            );

            register_post_type('Classes', $args2);

            $labels3 = array(
                'name' => _('Lessons'),
                'singular_name' => _('Lesson'),
                'add_new' => _('Add New Lesson'),
                'add_new_item' => _('Add New Lesson'),
                'edit_item' => _('Edit Lesson'),
                'new_item' => _('New Lesson'),
                'view_item' => _('View Lesson'),
                'search_items' => _('Search Lesson'),
                'not_found' => _('Nothing found'),
                'not_found_in_trash' => _('Nothing found in Trash'),
            );

            $args3 = array(
                'labels' => $labels3,
                'public' => true,
                'publicly_queryable' => true,
                'show_ui' => true,
                'query_var' => true,
                'rewrite' => true,
                'capability_type' => 'post',
                'hierarchical' => false,
                'menu_position' => 20,
                'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
            );

            register_post_type('Lessons', $args3);

            $labels4 = array(
                'name' => _('sparks'),
                'singular_name' => _('spark'),
                'add_new' => _('Add New spark'),
                'add_new_item' => _('Add New spark'),
                'edit_item' => _('Edit spark'),
                'new_item' => _('New spark'),
                'view_item' => _('View spark'),
                'search_items' => _('Search spark'),
                'not_found' => _('Nothing found'),
                'not_found_in_trash' => _('Nothing found in Trash'),
            );

            $args4 = array(
                'labels' => $labels4,
                'public' => true,
                'publicly_queryable' => true,
                'show_ui' => true,
                'query_var' => true,
                'rewrite' => true,
                'capability_type' => 'post',
                'hierarchical' => false,
                'menu_position' => 21,
                'supports' => array('title', 'editor', 'comments'),
            );
            register_post_type('Headline', $args4);
        }

        /*         * *****************************************************************************************
         * function for registering classes taxonomy
         * ***************************************************************************************** */

        function ez_classes_taxonomy() {
            register_taxonomy(
                    'Class-type',
                    'classes',
                    array(
                        'hierarchical' => true,
                        'label' => 'Course Type',
                        'query_var' => true,
                        'rewrite' => array('slug' => 'class-type')
                    )
            );
        }

        add_action('init', 'ez_classes_taxonomy');

        function register_ed_footer_menus() {
            register_nav_menus(
                    array(
                        'footer-menu' => __('Footer Menu'),
                    )
            );
        }

        add_action('init', 'register_ed_footer_menus');

        /*         * *****************************************************************************************
         * hook for registering script in backend
         * ***************************************************************************************** */
        add_action('admin_enqueue_scripts', 'ez_function_scripts');

        /*         * *****************************************************************************************
         * function for registering scripts
         * ***************************************************************************************** */

        function ez_function_scripts() {
            wp_register_style('main_admin', get_bloginfo('stylesheet_directory') . '/css/main_admin.css');
            wp_register_style('jquery_ui_css', get_bloginfo('stylesheet_directory') . '/css/jquery-ui.css');
            wp_register_script('jquery_ui_js', get_bloginfo('stylesheet_directory') . '/js/jquery-ui.js');
            wp_register_script('custom_admin_js', get_bloginfo('stylesheet_directory') . '/js/custom-admin.js', array('jquery'));
            wp_enqueue_style('main_admin');
            wp_enqueue_style('thickbox');
            wp_enqueue_script('thickbox');
            wp_enqueue_style('jquery_ui_css');
            wp_enqueue_script('jquery_ui_js');
            wp_enqueue_script('custom_admin_js');
            wp_localize_script('custom_admin_js', 'ajax_obj', array('ajaxurl' => admin_url('admin-ajax.php')));
        }

        /*         * *****************************************************************************************
         * hook for registering script in frontend
         * ***************************************************************************************** */

        add_action('wp_enqueue_scripts', 'ez_frontend_scripts');

        /*         * *****************************************************************************************
         * function for registering scripts in frontend
         * ***************************************************************************************** */

        function ez_frontend_scripts() {
            wp_register_style('jquery_custom_scrollbar_css', get_bloginfo('stylesheet_directory') . '/custom-scrollbar/jquery.custom-scrollbar.css');
            wp_register_script('jquery_custom_scrollbar_js', get_bloginfo('stylesheet_directory') . '/custom-scrollbar/jquery.custom-scrollbar.js', array('jquery'));
            wp_register_style('jquery_fancybox_css', get_bloginfo('stylesheet_directory') . '/fancybox/source/jquery.fancybox.css');
            wp_register_script('jquery_fancybox_js', get_bloginfo('stylesheet_directory') . '/fancybox/source/jquery.fancybox.js', array('jquery'));
            wp_register_script('jquery_fancybox_pack_js', get_bloginfo('stylesheet_directory') . '/fancybox/source/jquery.fancybox.pack.js', array('jquery'));
            wp_register_script('jquery_fancybox_media_js', get_bloginfo('stylesheet_directory') . '/fancybox/source/helpers/jquery.fancybox-media.js', array('jquery'));
            wp_register_script('custom_js', get_bloginfo('stylesheet_directory') . '/js/custom.js', array('jquery'));
            wp_enqueue_style('jquery_custom_scrollbar_css');
            wp_enqueue_style('jquery_fancybox_css');
            wp_enqueue_script('jquery_custom_scrollbar_js');
            wp_enqueue_script('jquery_fancybox_js');
            wp_enqueue_script('jquery_fancybox_pack_js');
            wp_enqueue_script('jquery_fancybox_media_js');
            wp_enqueue_script('custom_js');
            wp_localize_script('custom_js', 'ajax_obj', array('ajaxurl' => admin_url('admin-ajax.php'),'home_url' => home_url()));
        }

        /*         * *****************************************************************************************
         * function for custom pagination
         * ***************************************************************************************** */

        function custom_pagination() {
            global $wp_query;
            $big = 12345678;
            $page_format = paginate_links(array(
                        'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
                        'format' => '?paged=%#%',
                        'current' => max(1, get_query_var('paged')),
                        'total' => $wp_query->max_num_pages,
                        'type' => 'array'
                    ));
            if (is_array($page_format)) {
                $paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
                echo '<div><ul>';
                echo '<li><span>' . $paged . ' of ' . $wp_query->max_num_pages . '</span></li>';
                foreach ($page_format as $page) {
                    echo "<li>$page</li>";
                }
                echo '</ul></div>';
            }
        }

        add_action('init', 'custom_login_redirect');

        function custom_login_redirect() {
            // not the login request?
            if (!isset($_POST['action']) || $_POST['action'] !== 'custom_login_action')
                return;
            $creds = array();
            $creds['user_login'] = $_POST['ez-signed-username'];
            $creds['user_password'] = $_POST['ez-signed-pass'];
            $creds['remember'] = true;
            $user = wp_signon($creds, false);

            if (is_wp_error($result))
                wp_die('Login failed. Wrong password or user name?');

            // redirect back to the requested page if login was successful
            header('Location: ' . home_url());
            exit;
        }

        add_action('after_setup_theme', 'remove_admin_bar');

        function remove_admin_bar() {
            if (!current_user_can('administrator') && !is_admin()) {
                show_admin_bar(false);
            }
        }

        function ez_content_wordlimit($content, $word_limit, $dots = true) {
            $cont_array = explode(' ', $content);
            if (count($cont_array) > $word_limit) {
                if ($dots) {
                    $content = implode(' ', array_slice($cont_array, 0, $word_limit)) . ' ...';
                } else {
                    $content = implode(' ', array_slice($cont_array, 0, $word_limit));
                }
            }
            $content = apply_filters('the_content', $content);
            $content = force_balance_tags($content);
            return $content;
        }

        add_action('wp_ajax_nopriv_ez_sent_mail', 'ez_sent_email');
        add_action('wp_ajax_ez_sent_mail', 'ez_sent_email');

        function ez_sent_email() {
            global $wpdb;
            $email = $_POST['email'];
            $ajax = $_POST['ajax'];
            if ($ajax) {
                $user_count = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->users}` WHERE  `user_email`='$email'");
                if ($user_count == 1) {
                    $query = $wpdb->get_results("SELECT `user_login`,`user_pass` FROM `{$wpdb->users}` WHERE  `user_email`='$email'");
                    if ($query) {
                        $username = $query->user_login;
                        $password = $query->user_pass;
                    }
                } else {
                    $message = "You are not Registered with us";
                }
            }
        }

        add_action('login_form_middle', 'added_login_field');

        function added_login_field() {
            $return = '<p class="login_access">
                    <label for="login_access_code">Access code</label>
                    <input type="text"  size="20" value="" class="input" id="login_access_code" name="login_access_code">
                </p>
                 <p class="lost-pass"> If you are a member of a private study group<br/>
                           enter your access code here.
                       </p>
                <a class="lost-pass" style="color:red" href="' . home_url() . '/password-reset">Lost Password</a><br>';
            return $return;
        }

        add_action('init', 'session_manager');

        function session_manager() {
            if (!session_id()) {
                session_start();
            }
        }

        add_action('wp_logout', 'session_logout');

        function session_logout() {
            session_destroy();
        }

        add_filter('authenticate', 'check_login', 10, 3);

        function check_login($user, $username, $password) {
            global $wpdb, $private_table;
            $referrer = wp_get_referer();
            $user = get_user_by('login', $username);
            $acess_code = $_POST['login_access_code'];

            if (empty($username) || empty($password)) {
                $error = new WP_Error();
                $user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username or incorrect password.'));
                return $error;
            }
            if (is_email($username) && !($acess_code)) {
                $user_obj = get_user_by_email($username);
                if ($user_obj)
                    $username = $user_obj->user_login;
                return wp_authenticate_username_password($user, $username, $password);
            }
            else if (is_email($username) && $acess_code) {
                $user_obj = get_user_by_email($username);
                if ($user_obj)
                    $username = $user_obj->user_login;
                $custom_que = $wpdb->get_row("SELECT `group_members` FROM `{$private_table}` WHERE `Access_code`='{$acess_code}' ");
                $user_email = $wpdb->get_row("SELECT `user_email` FROM `{$wpdb->users}` WHERE `user_login`='{$username}' ");
                $explode_it = explode(',', $custom_que->group_members);
                $found_array = array_map('strtolower', $explode_it);
                if (in_array(strtolower($user_email->user_email), $found_array)) {
                    $_SESSION['access_code'] = $acess_code;
                    return wp_authenticate_username_password($user, $username, $password);
                } else {
                    remove_action('authenticate', 'wp_authenticate_username_password', 20);
                    wp_redirect(add_query_arg('access', 'failed', $referrer));
                    exit;
                }
            }
            if (!($acess_code)) {
                $_SESSION['access_code'] = '';
                return $_SESSION['access_code'];
            } else {
                $custom_que = $wpdb->get_row("SELECT `group_members` FROM `{$private_table}` WHERE `Access_code`='{$acess_code}' ");
                $user_email = $wpdb->get_row("SELECT `user_email` FROM `{$wpdb->users}` WHERE `user_login`='{$username}' ");
                $explode_it = explode(',', $custom_que->group_members);
                $found_array = array_map('strtolower', $explode_it);
                if (in_array(strtolower($user_email->user_email), $found_array)) {
                    $_SESSION['access_code'] = $acess_code;
                    return $_SESSION['access_code'];
                } else {
                    remove_action('authenticate', 'wp_authenticate_username_password', 20);
                    wp_redirect(add_query_arg('access', 'failed', $referrer));
                    exit;
                }
            }
        }

        // On failure, notify the custom form through a redirect with a new query variable
        add_action('wp_login_failed', 'custom_login_failed');

// When a user leaves a field blank, return that as an error that will fire wp_login_failed

        function custom_login_failed($username) {
            $referrer = wp_get_referer();
            if ($referrer && !strstr($referrer, 'wp-login') && !strstr($referrer, 'wp-admin')) {
                wp_redirect(add_query_arg('login', 'failed', $referrer));
                exit;
            }
        }

        function blaze_login_redirect($redirect_to, $request, $user) {
            return ( is_array($user->roles) && in_array('administrator', $user->roles) ) ? admin_url() : site_url();
        }

// end soi_login_redirect
        add_filter('login_redirect', 'blaze_login_redirect', 10, 3);


        add_action('wpcf7_before_send_mail', 'custom_conversion');

        function custom_conversion(&$WPCF7_ContactForm) {
            global $post, $current_user, $wpdb, $user_tracking, $private_table;
            preg_match_all('#<p>([^<>]*<br\s*/?>[^<>]*)+</p>#s', $WPCF7_ContactForm->form, $district);
            $explode_it_1 = explode('<br />', $district[1][0]);
            $explode_it_2 = explode('<br />', $district[1][1]);
            $explode_it_3 = explode('<br />', $district[1][2]);
            $p_id = $WPCF7_ContactForm->posted_data["text-703"];
            $field1 = $WPCF7_ContactForm->posted_data["textarea-339"];
            $field2 = $WPCF7_ContactForm->posted_data["textarea-743"];
            $field3 = $WPCF7_ContactForm->posted_data["textarea-719"];
            $user_id = $current_user->ID;
            $content = $field1 . '||' . $field2 . '||' . $field3;
            if ($p_id && $user_id) {
                $user_query = ("SELECT COUNT(*) FROM `{$user_tracking}` WHERE `user_id`= $user_id AND `post_id`= $p_id");
                $data_query = $wpdb->get_var($user_query);
                if ($data_query == "0") {
                    $current_time = date("d-M-Y");
                    $customized_query = ("INSERT INTO `{$user_tracking}` VALUES('',$user_id,$p_id,'$current_time','$content')");
                    $custom_query = $wpdb->query($customized_query);
                    if ($custom_query) {
                        $class = get_the_title($p_id);
                        $admin_email = get_settings('admin_email');
                        $user_mail = $current_user->user_email;
                        $message = __($class . ' is successfully evaluated by ' . $current_user->user_login) . "\r\n\r\n";
                        $message .= __($explode_it_1[0]) . "\r\n\r\n";
                        $message .= __('Ans->' . $field1 . '') . "\r\n\r\n";
                        $message .= __($explode_it_2[0]) . "\r\n\r\n";
                        $message .= __('Ans->' . $field2 . '') . "\r\n\r\n";
                        $message .= __($explode_it_3[0]) . "\r\n\r\n";
                        $message .= __('Ans->' . $field3 . '') . "\r\n\r\n";
                        if ($_SESSION['access_code']) {
                            $query = $wpdb->get_row("SELECT `group_creator` FROM `{$private_table}` WHERE `Access_code` ='{$_SESSION['access_code']}'");
                            if ($query) {
                                $email_query = $wpdb->get_row("SELECT `user_email` FROM `{$wpdb->users}` WHERE `user_login` ='{$query->group_creator}'");
                                if ($email_query) {
                                    wp_mail(array($email_query->user_email, $user_mail), $class . ' Evaluated', $message);
                                }
                            }
                        } else {
                            wp_mail(array($admin_email, $user_mail), $class . ' Evaluated', $message);
                        }
                    }
                }
            }
        }

        /*
         * filtering registration form
         */

        function custom_reg_validation($errors) {
            if ($_POST['country'] == 'USA' && $_POST['state'] == '') {
                $errors[] = "Your country is USA So State is a required field";
            }
            return $errors;
        }

        add_filter('simplr_validate_form', 'custom_reg_validation', 0, 1);

        /*
         * adding extra feilds in comment forms
         */

        add_action('comment_form_logged_in_after', 'additional_fields');
        add_action('comment_form_after_fields', 'additional_fields');

        function additional_fields() {
            global $post;
            echo '<p class="comment-form-title">' .
            '<input id="com_access_code" name="com_access_code" type="hidden" size="30"  tabindex="5" value="' . $_SESSION['access_code'] . '"/>
            <input id="com_post_id" name="com_post_id" type="hidden" size="30"  tabindex="5" value="' . $post->ID . '"/></p>';
        }

        add_action('comment_post', 'save_comment_meta_data');

        function save_comment_meta_data($comment_id) {
            if (( isset($_POST['com_access_code']))) {
                $com_access_code = wp_filter_nohtml_kses($_POST['com_access_code']);
                add_comment_meta($comment_id, 'com_access_code', $com_access_code);
            }
            if (( isset($_POST['com_post_id']))) {
                $com_post_id = wp_filter_nohtml_kses($_POST['com_post_id']);
                add_comment_meta($comment_id, 'com_post_id', $com_post_id);
            }
        }

        add_action('edit_comment', 'extend_comment_edit_metafields');

        function extend_comment_edit_metafields($comment_id) {
            if (!isset($_POST['extend_comment_update']) || !wp_verify_nonce($_POST['extend_comment_update'], 'extend_comment_update'))
                return;
            if (( isset($_POST['com_access_code']))):
                $com_access_code = wp_filter_nohtml_kses($_POST['com_access_code']);
                update_comment_meta($comment_id, 'com_access_code', $com_access_code);
            else :
                delete_comment_meta($comment_id, 'com_access_code');
            endif;
            if (( isset($_POST['com_post_id']))):
                $com_post_id = wp_filter_nohtml_kses($_POST['com_post_id']);
                update_comment_meta($comment_id, 'com_post_id', $com_post_id);
            else :
                delete_comment_meta($comment_id, 'com_post_id');
            endif;
        }

        /**
         * Change wp_mail's from name
         */
        function iweb_change_from_name($name = '') {
            return get_bloginfo('name');
        }

        add_filter('wp_mail_from_name', 'iweb_change_from_name');

        /**
         * Change wp_mail's from email
         */
        function iweb_change_from_email($email = '') {
            return get_bloginfo('admin_email');
        }

        add_filter('wp_mail_from', 'iweb_change_from_email');

        add_action('restrict_manage_comments', 'custom_filter_comments');

        function custom_filter_comments() {
            global $wpdb, $private_table;
            $cc_code = $_GET['ez_group_name'];
            $sql = "SELECT `Access_code`,`group_name` FROM `{$private_table}`";
            $available_groups = $wpdb->get_results($sql);
?>
            <select name="ez_group_name">
                <option value="" <?php selected($cc_code, ""); ?>>Select a Group</option>
    <?php foreach ($available_groups as $code) {
    ?>
                <option value="<?php echo $code->Access_code; ?>" <?php selected($cc_code, $code->Access_code); ?>><?php echo $code->group_name; ?></option>
    <?php } ?>
        </select>
<?php
        }

        add_action('restrict_manage_posts', 'ez_group_dropdown');

        function ez_group_dropdown() {
            global $typenow, $wpdb, $private_table;
            if ($typenow == 'headline') {
                $headline_code = $_GET['group_headline_code'];
                $sql = "SELECT `Access_code`,`group_name` FROM `{$private_table}`";
                $available_groups = $wpdb->get_results($sql);
?>
                <select name="group_headline_code">
                    <option value="" <?php selected($headline_code, ""); ?>>Select a Group</option>
                    <option value="public-group" <?php selected($headline_code, "public-group"); ?>>Public Group</option>
    <?php foreach ($available_groups as $code) {
    ?>
                    <option value="<?php echo $code->Access_code; ?>" <?php selected($headline_code, $code->Access_code); ?>><?php echo $code->group_name; ?></option>
    <?php } ?>
            </select>
<?php
            }
        }

        add_filter('parse_query', 'bs_event_table_filter');

        function bs_event_table_filter($query) {
            if (is_admin() AND $query->query['post_type'] == 'headline') {
                $qv = &$query->query_vars;
                $qv['meta_query'] = array();


                if (!empty($_GET['group_headline_code'])) {
                    if ($_GET['group_headline_code'] == 'public-group') {
                        $get_in = '';
                    } else {
                        $get_in = $_GET['group_headline_code'];
                    }
                    $qv['meta_query'][] = array(
                        'field' => 'post_id_code',
                        'value' => $get_in,
                    );
                }
            }
        }

        add_action('current_screen', 'wpse_72210_comments_exclude_lazy_hook', 10, 2);

        /**
         * Delay hooking our clauses filter to ensure it's only applied when needed.
         */
        function wpse_72210_comments_exclude_lazy_hook($screen) {
            if ($screen->id != 'edit-comments')
                return;

            // Check if our Query Var is defined
            if ($_GET['ez_group_name'] && is_admin())
                add_filter('the_comments', 'custom_list_comments', 10, 1);
        }

        function custom_list_comments($comments) {
            foreach ($comments as $i => $comment) {
                $meta = strtolower(get_comment_meta($comment->comment_ID, 'com_access_code', true));
                if ($meta != strtolower($_GET['ez_group_name'])) {
                    unset($comments[$i]);
                }
            }
            return $comments;
        }

        add_action('wp_ajax_nopriv_manage_members', 'ez_manage_members');
        add_action('wp_ajax_manage_members', 'ez_manage_members');

        function ez_manage_members() {
            global $wpdb, $private_table;
            $message = '';
            $acess_code = $_POST['access_code'];
            $mem_val = $_POST['mem_val'];
            if ($acess_code) {
                $que = ("UPDATE `{$private_table}` SET `group_members`='$mem_val' WHERE `Access_code`='$acess_code'");
                $query = $wpdb->query("UPDATE `{$private_table}` SET `group_members`='$mem_val' WHERE `Access_code`='$acess_code'");
                $message = "You have successfully edited members of this group";
            } else {
                $message = "Editing is disabled try after sometime";
            }
            die(json_encode($message));
        }

        add_action('wp_ajax_nopriv_delete_group', 'ez_delete_group');
        add_action('wp_ajax_delete_group', 'ez_delete_group');

        function ez_delete_group() {
            global $wpdb, $private_table;
            $message = '';
            $acess_code = $_POST['access_code'];
            if ($acess_code) {
                $again_query = $wpdb->get_results("SElECT `post_id` FROM `{$wpdb->postmeta}` WHERE `meta_value`='$acess_code'", ARRAY_A);
                if ($again_query) {
                    foreach ($again_query as $a_q) {
                        $aid = $a_q['post_id'];
                        $inner_query = $wpdb->query("DELETE FROM `{$wpdb->posts}` WHERE `ID`= $aid");
                    }
                }
                $query = $wpdb->query("DELETE FROM `{$private_table}` WHERE `Access_code`='$acess_code'");
                $message = "You have successfully deleted this group";
            }
            die(json_encode($message));
        }

        function robins_get_the_excerpt($post_id) {
            global $post;
            $save_post = $post;
            $post = get_post($post_id);
            $output = get_the_excerpt();
            $post = $save_post;
            return $output;
        }

        add_filter('simplr_extra_message', 'custom_registration_message');

        function custom_registration_message($extra) {
            $extra = "Please check your email for confirmation. Also check your spam folder if email doesn't appear in your inbox";
            return $extra;
        }

        add_action('wp_ajax_nopriv_list_users', 'list_users');
        add_action('wp_ajax_list_users', 'list_users');

        function list_users() {
            global $wpdb, $user_tracking;
            $message = '';
            $count = 1;
            $custom_text = $_POST['custom_text'];
            if ($custom_text) {
                $user_query = $wpdb->get_results("SELECT * FROM  `{$wpdb->users}` WHERE `user_login`!='admin' AND `user_login` LIKE '$custom_text%'");
                if ($user_query) {
                    $meta_value = get_option('_head_badges');
                    foreach ($user_query as $user_q) {
                        $custom_query = $wpdb->get_results("SELECT `post_id` FROM `{$user_tracking}` WHERE `user_id`= $user_q->ID ORDER BY `post_id` ASC");
                        echo '<tr>
                        <td width="10%" style="text-align:center">' . $count . ')</td>
                    <td width="30%" style="text-align:center" >' . $user_q->user_login . '</td>
                     <td>';
                        foreach ($meta_value as $key => $value) {
                            foreach ($custom_query as $cus_q) {
                                if ($key == $cus_q->post_id) {
                                    $title = get_the_title($cus_q->post_id);
                                    echo "<div class='badges_images' style='float:left;'><h4>$title</h4><span class='class-img'><img src=" . $value . "></span></div>";
                                }
                            }
                        }
                        echo '</td>';
                        $count++;
                        echo '<tr>';
                    }
                } else {
                    echo "<th></th><th>No users Found</th><th></th>";
                }
            }
            die();
        }

        add_action('wp_ajax_nopriv_list_tracking_users', 'list_tracking_users');
        add_action('wp_ajax_list_tracking_users', 'list_tracking_users');

        function list_tracking_users() {
            global $wpdb, $user_tracking;
            $custom_text = $_POST['custom_text'];

            $new_query = $wpdb->get_results("SELECT * FROM  `{$wpdb->users}` WHERE `user_login`!='admin' AND `user_login` LIKE '$custom_text%'");
            if ($new_query) {
?>
                <div class="accordion">
    <?php
                foreach ($new_query as $user_q) {
    ?>
                    <h3><?php echo $user_q->user_login; ?></h3>
    <?php
                    $customization_query = $wpdb->get_results("SELECT `post_id` FROM  `{$user_tracking}` WHERE `user_id`= $user_q->ID ORDER BY `post_id` ASC");
    ?>
                    <div>
                        <p>
            <?php if (!$customization_query) {
            ?>
                    <div class="no-class">
            <?php _e("This User not Evaluated any Class"); ?>
                    </div>
        <?php } ?>
                    <div class="accordion">
            <?php
                    foreach ($customization_query as $custom_q) {
                        $evaluation_content = $wpdb->get_row("SELECT `Evaluation_answers` FROM  `{$user_tracking}` WHERE `user_id`= $user_q->ID  AND `post_id`= $custom_q->post_id");
                        $evaluaton_con = explode('||', $evaluation_content->Evaluation_answers);
            ?>
                        <h3><?php echo get_the_title($custom_q->post_id); ?></h3>
                        <div>
                            <ul>
                                <li>1) What was the general themes of this course?</li>
                                <span> Ans: <?php echo $evaluaton_con[0]; ?></span>
                                <li>2) What were the major thought or conscience difficulties that the Holy Spirit brought to your attention through this course?</li>
                                <span>Ans: <?php echo $evaluaton_con[1]; ?></span>
                                <li>3) How can what you learned through this course be useful for today’s Kingdom work?</li>
                                <span>Ans: <?php echo $evaluaton_con[2]; ?></span>
                            </ul>
                        </div>
            <?php
                    }
                    $eval_learned = get_user_meta($user_q->ID, 'eval_learned', true);
                    $util_learned = get_user_meta($user_q->ID, 'util_learned', true);
                    if ($eval_learned && $util_learned) {
            ?>
                        <h3><?php _e('Graduation Evaluation'); ?></h3>
                        <div>
                            <ul>
                                <li>1. What have you learned?</li>
                                <span> Ans: <?php echo $eval_learned; ?></span>
                                <li>2. How will you use what you have learned?</li>
                                <span>Ans: <?php echo $util_learned; ?></span>
                            </ul>
                        </div>
            <?php
                    }
            ?>
                </div>
                </p>
            </div>
    <?php
                }
    ?>
            </div>
<?php
            } else {
                echo '<span style="text-align: center; width: 100%; display: block;">No Users found</span>';
            }
?>
<?php
            die();
        }

        function user_last_login($user_login, $user) {
            update_user_meta($user->ID, '_last_login', time());
            delete_user_meta($user->ID, 'deleted_date');
        }

        add_action('wp_login', 'user_last_login', 10, 2);

        add_filter( 'comment_form_field_comment', 'comment_editor' );

function comment_editor() {
global $post;

ob_start();

wp_editor( '', 'comment', array(
        'media_buttons' => true,
        'teeny' => true,
        'textarea_rows' => '7',
        'tinymce' => array( 'plugins' => $mce_plugins, 'content_css' => get_stylesheet_directory_uri() . '/editor-style.css' )
    ) );

$editor = ob_get_contents();

ob_end_clean();

//make sure comment media is attached to parent post
$editor = str_replace( 'post_id=0', 'post_id='.get_the_ID(), $editor );

return $editor;
}

// wp_editor doesn't work when clicking reply. Here is the fix.
add_action( 'wp_enqueue_scripts', '__THEME_PREFIX__scripts' );
function __THEME_PREFIX__scripts() {
    wp_enqueue_script('jquery');
}
add_filter( 'comment_reply_link', '__THEME_PREFIX__comment_reply_link' );
function __THEME_PREFIX__comment_reply_link($link) {
    return str_replace( 'onclick=', 'data-onclick=', $link );
}
add_action( 'wp_head', '__THEME_PREFIX__wp_head' );
function __THEME_PREFIX__wp_head() {
?>
<script type="text/javascript">
jQuery(function($){
$('.comment-reply-link').click(function(e){
e.preventDefault();
var args = $(this).data('onclick');
args = args.replace(/.*\(|\)/gi, '').replace(/\"|\s+/g, '');
args = args.split(',');
tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'comment');
addComment.moveForm.apply( addComment, args );
tinymce.EditorManager.execCommand('mceAddEditor', true, 'comment');
});
});
</script>
<?php }

add_action( 'delete_post', 'custom_func');

function custom_func($postid){
    if ( 'headline' != get_post_type( $post_id )){
        delete_post_meta($post_id, 'post_id_code');
    }
}

         
add_filter( 'cron_schedules', 'bl_add_cron_intervals' );

function bl_add_cron_intervals( $schedules ) {
   $schedules['2seconds'] = array( // Provide the programmatic name to be used in code
      'interval' => 2, // Intervals are listed in seconds
      'display' => __('Every 2 Seconds') // Easy to read display name
   );
   return $schedules; // Do not forget to give back the list of schedules!
}

add_action( 'bl_cron_hook', 'bl_cron_exec' );
if( !wp_next_scheduled( 'bl_cron_hook' ) ) {
   wp_schedule_event( time(), '2seconds', 'bl_cron_hook' );
}

function bl_cron_exec(){
    global $wpdb;
    $query = $wpdb->get_results("SELECT *
                            FROM `wp_users`
                        WHERE `user_status`='2'");
    if($query){
        foreach($query as $q){
            $last_login = get_user_meta($q->ID, '_last_login', true);
            if($last_login){
                $custom_query = $wpdb->query("UPDATE `wp_users`
                            SET `user_status`='0'
                        WHERE `ID`='$q->ID'");
            }
        }
    }
}


===
adding ajax in wp
=======================
in function.php

function custom_scripts_method(){
wp_register_script('custom_front_end_js', get_bloginfo('stylesheet_directory') . '/js/custom_front_end.js', array('jquery'));
wp_enqueue_script('custom_front_end_js');
wp_localize_script('custom_front_end_js', 'ajax_obj', array('ajaxurl' => admin_url('admin-ajax.php')));
}

add_action('wp_ajax_nopriv_test', 'sadanand_test');
add_action('wp_ajax_test', 'sadanand_test');

function sadanand_test(){
 global $wpdb;
 $id = $_POST['id'];
  if($id){
  $my_postid = $id;//This is page id or post id
  $content_post = get_post($my_postid);
 $content = $content_post->post_content;
 $content = apply_filters('the_content', $content);
 $content = str_replace(']]>', ']]&gt;', $content);
 echo $content;
  die();
  }
  die();
}
custom_front_end.js

var $ = jQuery;
$(document).ready(function(){
 jQuery('.view_post').on('click','a',function(){
  var id = $(this).attr('id');
  if(id){
   jQuery.ajax({
                type: 'POST',
                url: ajax_obj.ajaxurl,
                data: 'action=test&id='+id,
                success: function(data) {
                    if (data) {
                        $('.app_content').html('');
$('.app_content').html(data);
                    }
                }
            });
  }
 })
})

view-post.php
<?php
/**
 * Template Name: view_post page
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */

get_header(); ?>

<div id="main-content" class="main-content">

<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>

<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<div class="view_post">
<?php
$count = 1;
$my_content = '';
wp_reset_query();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('post_type' => 'post',
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 10,
'orderby' => 'ID',
'order' => 'ASC',
);
query_posts($args);
?>
                <?php if ( have_posts() ) : while (have_posts()) : the_post();
$p_id = get_the_id();
$title=get_the_title();
if($count == 1){
$my_postid = $p_id;//This is page id or post id
                     $content_post = get_post($my_postid);
                   $content = $content_post->post_content;
                    $content = apply_filters('the_content', $content);
                   $content = str_replace(']]>', ']]&gt;', $content);
$my_content = $content;
}
                       
?>
                          <dl>
                        <a href="javascript:void(0);" id="<?php echo $p_id; ?>"><?php echo get_the_title();?></a>
<dt>
                            <strong><?php //the_date();
//echo get_the_date();
?></strong>
   <!--<span>Category : <?php $cat=get_the_category($p_id); echo $cat[0]->name;?></span>-->
</dt>

                    </dl>

       
       
<?php $count++; endwhile; ?>
<?php endif; ?>
                <div class="clear"></div>
      <div class="app_content"><?php echo $my_content; ?></div>
</div>

<?php
// If comments are open or we have at least one comment, load up the comment template.
/* if ( comments_open() || get_comments_number() ) {
comments_template();
} */

?>
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main-content -->

<?php
get_sidebar();
get_footer();
===================


2.


/*******Add Custom post*********/
add_action( 'init', 'create_post_type' );
function create_post_type() {
  register_post_type( 'our_portfolio',
    array(
      'labels' => array(
        'name' => __( 'Our Portfolio' ),
        'singular_name' => __( 'Our Protfolio' )
      ),
      'public' => true,
      'has_archive' => true,
 'supports' => array('thumbnail', 'title', 'editor'),
    )
  );


/***********add texonomy****************/
add_action( 'init', 'create_book_tax' );

function create_book_tax() {
register_taxonomy(
'porfolio_category',
'our_portfolio',
array(
'label' => __( 'Category' ),
'rewrite' => array( 'slug' => 'porfolio_category' ),
'hierarchical' => true,
)
);
}

<?php

/**

 * Template Name: Home Page

 *

 * @package WordPress

 * @subpackage Twenty_Fourteen

 * @since Twenty Fourteen 1.0

 */



get_header();

global $wpdb;

?>





<div id="main-content" class="main-content">



<?php

/*if ( is_front_page() && twentyfourteen_has_featured_posts() ) {

// Include the featured content template.

get_template_part( 'featured-content' );

}*/

?>



<div id="primary" class="content-area">

<div id="content" class="site-content" role="main">

<div class="row">

                <div class="home_slider">

<?php echo do_shortcode('[cycloneslider id="slider1"]'); ?>

                        <span class="slider_shadow"></span>

                  </div>

                </div>

               

                <div class="row professional_website">

                <div class="container">

<?php

$p_id = get_the_id();

$meta_values = get_post_meta( $p_id, 'editor' );

print_r($meta_values[0]);



?>

                    <div class="clear"></div>

                   <!-- <a href="javascript:;" class="btn">Get started now</a>-->

                </div>

                </div>

               

                <div class="row">

                <div class="container Our_Portfolio">

                      <h1 class="title">Our Portfolio</h1>

                     

                     

                        <?php ?>







<div id="tabs">

<ul>

<li><a href="#tabs-1">All</a></li>

<?php

wp_reset_query();

$post_type_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'our_portfolio' AND post_status = 'publish'");

                              if(!empty ($post_type_ids )){

                                $post_type_cats = wp_get_object_terms( $post_type_ids, 'porfolio_category',array('orderby' => 'name', 'fields' => 'ids') );

                                if($post_type_cats){

                                  $post_type_cats = array_unique($post_type_cats);

                                }

                              }

                              $include_category = null;

                                if(!empty ($post_type_ids )){

$i=2;

                                     foreach ($post_type_cats as $category_list) {

                                        $cat =  $category_list.",";

                                        $include_category = $include_category.$cat;

                                        $cat_name = get_term($category_list, 'porfolio_category');

                                ?>

                                <li><a href="#tabs-<?=$i;?>" data-filter="<?php echo '.class-'.$category_list;?>"><?php echo $cat_name->name; ?></a></li>

                            <?php $i++;} }?>





</ul>

<div id="tabs-1">

<div id="myScroller-1">

<?php wp_reset_query();

$args=array(

 'post_type' => 'our_portfolio',

 'post_status' => 'publish',

 'posts_per_page' => -1,



 );



$my_query = new WP_Query($args);

if( $my_query->have_posts() ) {

  while ($my_query->have_posts()) : $my_query->the_post();

$p_id = get_the_id();

$meta_values = get_post_meta( $p_id, 'web-site_link' );

// print_r ($meta_values);



if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.

?><div class="scroller-el"><a href="<?php echo $meta_values[0];  ?>" target="_blank" ><?php the_post_thumbnail(array(305,305)); ?><?php //$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );?>

<!--<img src="<?php echo $url; ?>" longdesc="URL_2" alt="Text_2"  />--></a></div><?php

}

endwhile;

}

 ?></div>

</div>

<?php



 $j=2;

foreach ($post_type_cats as $category_list) {

                                        $cat =  $category_list.",";

                                        $include_category = $include_category.$cat;

                                        $cat_name = get_term($category_list, 'porfolio_category');

                                ?>



                                <div id="tabs-<?=$j;?>">

<div id="myScroller-<?=$j;?>">

<?php wp_reset_query();

$args=array(

 'post_type' => 'our_portfolio',

 'post_status' => 'publish',

 'posts_per_page' => -1,

'porfolio_category'    => $cat_name->slug,

 );

 $my_query = new WP_Query($args);

if( $my_query->have_posts() ) {

  while ($my_query->have_posts()) : $my_query->the_post();

$p_id = get_the_id();

$meta_values = get_post_meta( $p_id, 'web-site_link' );

// print_r ($meta_values);



if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.

?><div class="scroller-el"><a href="<?php echo $meta_values[0];  ?>" target="_blank" ><?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );?>

<img src="<?php echo $url; ?>" longdesc="URL_2" alt="Text_2"  /></a></div><?php

}

endwhile;



}





?></div></div>

                            <?php $j++;}

$j--;



?> <input type="hidden" name="portfolio_categeory_count" id="portfolio_categeory_count" value="<?php echo $j; ?> "/>



    </div>

    </div>

</div>

<?php





?>



    </div>



</div><!-- #content -->

</div><!-- #primary -->

</div><!-- #main-content -->



<?php

// get_sidebar();

get_footer();

==============================


Comments

Post a Comment

Popular posts from this blog

Create post with all post type

<?php /* add_action( 'wp_enqueue_scripts', 'mpcth_child_enqueue_scripts', 1000 ); function mpcth_child_enqueue_scripts() { wp_enqueue_style( 'mpc-styles-child', get_stylesheet_directory_uri() . '/style_custom.css' ); } */ function registration_form( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) { ?>     <style>       /* Always set the map height explicitly to define the size of the div        * element that contains the map. */     #map {     height: 260px; }     </style>   <script> function initMap() {     var map = new google.maps.Map(document.getElementById('map'), {       center: {lat: -33.8688, lng: 151.2195},       zoom: 13     });     var input = document.getElementById('searchInput');    // map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);    

Create Signature pad with save on database in php

Create Signature pad with save on database in php 1.create a folder images index.php ============   <!DOCTYPE >     <head>     <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />     <title>Signature Pad</title>     <script type="text/javascript" src="jquery-1.8.0.min.js"></script>     <script type="text/javascript"> $(document).ready(function () {     /** Set Canvas Size **/     var canvasWidth = 400;     var canvasHeight = 100;     /** IE SUPPORT **/     var canvasDiv = document.getElementById('signaturePad');     canvas = document.createElement('canvas');     canvas.setAttribute('width', canvasWidth);     canvas.setAttribute('height', canvasHeight);     canvas.setAttribute('id', 'canvas');     canvasDiv.appendChild(canvas);     if (typeof G_vmlCanvasManager != 'undefined') {        

WooCommerce Mini cart With Ajax

WooCommerce Mini cart //MINI CART SECTION   <div class="productdiv rightcart">                                                         <?php if ( ! WC()->cart->is_empty() ) : ?>     <ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">         <?php             do_action( 'woocommerce_before_mini_cart_contents' );             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {                 $_product     = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );                 $product_id   = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );                 if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_c