Sunday, February 19, 2017

Jquery for F12 and Right Click Disable


$(document).keydown(function(event){
    if(event.keyCode==123){
        return false;
    }
    else if (event.ctrlKey && event.shiftKey && event.keyCode==73){      
             return false;
    }
});

Tuesday, August 23, 2016

Wordpress Custom Post Loop Codex

<?php
/**
 * Template Name: Portfolio
 * The template for displaying portfolio posts.
 *
 */

get_header(); ?>

<div id="primary" class="content-area col-md-9">
<main id="main" class="site-main" role="main">
<?php

            $args = array( 'post_type' => 'portfolio', 'posts_per_page' => 9 );
            $loop = new WP_Query( $args );
            while ( $loop->have_posts() ) : $loop->the_post(); ?>

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

<?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();
endif;
?>

<?php endwhile; // end of the loop. ?>

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

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

Wednesday, May 4, 2016

Wordpress default Post Name Change Function.php


<?php

function change_post_menu_label() {

global $menu;

global $submenu;

$menu[5][0] = 'Projects';

$submenu['edit.php'][5][0] = 'Projects';

$submenu['edit.php'][10][0] = 'Add Projects';

$submenu['edit.php'][16][0] = 'Projects Tags';

echo '';

}

function change_post_object_label() {

global $wp_post_types;

$labels = &$wp_post_types['post']->labels;

$labels->name = 'Projects';

$labels->Portfolio = 'Projects';

$labels->add_new = 'Add New';

$labels->add_new_item = 'Add Projects';

$labels->edit_item = 'Edit Projects';

$labels->new_item = 'Projects';

$labels->view_item = 'View Projects';

$labels->search_items = 'Search Projects';

$labels->not_found = 'No Projects found';

$labels->not_found_in_trash = 'No Projects found in Trash';

}

add_action( 'init', 'change_post_object_label' );

add_action( 'admin_menu', 'change_post_menu_label' );



function the_slug() {

    $post_data = get_post($post->ID, ARRAY_A);

    $slug = $post_data['post_name'];

    return $slug;

}

?>


Friday, November 6, 2015

Single Page Current post Active Class

<?php if (have_posts()) : while (have_posts()) : the_post(); $current_project = get_the_ID(); ?>

Post Loop Header Before :






       <?php

$args = array( 'post_type' => 'knowus', 'posts_per_page' => 5, 'post_status' => 'any', 'post_parent' => null );

$attachments = get_posts( $args );

if ( $attachments ) {

foreach ( $attachments as $post ) {

setup_postdata( $post );

?>

   

    <?php if ( $post->ID == $current_project ) { ?>

    <li class="active"><a href="<?php the_permalink();?>">

      <?php the_title();?>

      </a></li>

  <?php } else { ?>

    <li><a href="<?php the_permalink(); ?>">

      <?php the_title();?>

      </a></li>

  <?php } ?>

   

   

    <?php }

wp_reset_postdata();

}
?>

Thursday, February 5, 2015

Wordpress Single Category Posts

<div class="col-md-8 happer_new">
         
               <?php  
$loop = new WP_Query( array('post_type' => 'home', 'home_category' => 'happy', 'posts_per_page' => 1 ) );
while ( $loop->have_posts() ) : $loop->the_post();
$postid = get_the_ID();
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_size' );
$url = $thumb['0'];
?>
   
            <h3 class="happier"><?php echo the_title();?></h3>
            <div class="col-md-4 nopaddding"> <?php echo the_post_thumbnail();?> </div>
            <div class="col-md-8">
           
            <?php echo the_content();?>
           
            </div>
           
              <?php endwhile;?>
          </div>

Pages Fastly Loader Script

jQuery(document).ready(function(){
// ajax pagination
jQuery('.navMenu li a').live('click', function(){
var link = jQuery(this).attr('href');
jQuery('#contentOver').html('loading…');
jQuery('#contentOver').load(link+' #content-left')
});
}); // end ready function

Thursday, December 18, 2014

Wordpress Category Loop and Posts Codex

<ul class="topnav">
          <?php
                                    $orderby = 'name';
                                    $taxonomy = 'category'; //slug name
                                    $args = array(
                                      'orderby' => $orderby,
                                      'taxonomy' => $taxonomy,
                                      'category__in' => array($category->term_id),
                                      'hide_empty'=> 0,

                                    );
                                    ?>
          <?php
                                      $m=1;
                                      $postid=$_REQUEST['pid'];
                                      $queried_post = get_post($postid);
                                      $title = $queried_post->post_title;
                                      $content= $queried_post->post_content;
                                      $image_path = wp_get_attachment_url(get_post_thumbnail_id($postid));
                                      $categories =  get_categories($args);
                                      foreach ($categories as $category)
                                      {                                                    
                                 ?>
          <li><a href="javascript:void(0)"><?php echo $category->cat_name; ?></a>
            <ul class="proCat">
              <?php
$m=1;
                                    $loop = new WP_Query( array('post_type' => 'post',
                                    'category_name'=>$category->slug ) );
                                    while ( $loop->have_posts() ) : $loop->the_post();
                                    $postid = get_the_ID();

?>
              <li <?php if ( $post->ID == $wp_query->post->ID ) { echo ' class="current"'; } else {} ?>><a href="<?php the_permalink();?>" class="">
                <?php the_title();?>
                </a></li>
              <?php $m=$m+1; endwhile;?>
            </ul>
            <?php  $m=$m+1; }  ?>
          </li>
        </ul>


Ref: http://www.ishaengineering.com/oil-squeezing-press/ - Sidebar