Saturday 5 November 2016

If Page specific id then code execute WordPress code?

IT NEW CODE gives a way to execute some code on only fix page.
We can do it by using page id.
Below is given code.
In this code if page id match then only code will be execute.


Here, 156 id is page id

Code is below:

<?php
if(is_page(156)){
// Put Your code Here
echo do_shortcode('[widget id="text-4"]');
}
?>



For more Interesting, Useful Article & codes visit IT New Code.
IT NEW CODE always help you with new Developing Code.


How to Hide WordPress Theme identity?

IT NEW CODE gives to rename a theme as your project or website name.
There are some steps to follow you.


1> Add following code in "function.php" file.
----------------------------------------
//
// To hide WP header identity
//
remove_action('wp_head', 'wp_generator');


//
//To Change Name Howdy in wp Admin top right Corner
//
function change_howdy($translated, $text, $domain) {

    if (!is_admin() || 'default' != $domain)
        return $translated;

    if (false !== strpos($translated, 'Howdy'))
        return str_replace('Howdy', 'Welcome', $translated);

    return $translated;
}
add_filter('gettext', 'change_howdy', 10, 3);


//
// Admin Side CSS
//
function my_custom_css() {
echo '<style>
#wp-admin-bar-wp-logo ,#wpfooter, #dashboard_primary, #wp-version-message, .welcome-panel h2, .welcome-panel .about-description, #adminmenu .wp-has-current-submenu .wp-submenu {
    display: none;
}
</style>';
}
add_action('admin_head', 'my_custom_css');




2> In "style.css" file following like code there.
----------------------------------------
/*
Theme Name: Twenty Fifteen
Theme URI: https://wordpress.org/themes/twentyfifteen/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen's simple, straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages. We designed it using a mobile-first approach, meaning your content takes center-stage, regardless of whether your visitors arrive by smartphone, tablet, laptop, or desktop computer.
Version: 1.5
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, blue, gray, pink, purple, white, yellow, dark, light, two-columns, left-sidebar, fixed-layout, responsive-layout, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready
Text Domain: twentyfifteen

This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/


In Above code Bold Letter value must be change. Others are optional.
Must Change Theme Name, Theme URI, Author, Author URI value.



For more Interesting, Useful Article & codes visit IT New Code.
IT NEW CODE always help you with new Developing Code.

How to add multiple header and footer in WordPress?


IT NEW CODE give a trick to make multiple header & footer  templates.
Sometimes We need multiple kind of look & client needs different header.
In such a case need to create multiple header files.
Below describes how to create multiple headwer & footer.

Create New Header:-
In Your theme defalt header file name as "header.php".
You create new header file like,"header-cast.php"
and put your code in it.

Now How to call this in your template? just put following code where you want to add.

<?php get_header('cast'); ?>


Create New Footer:-
Now, You can do same for footer.
You create new footer like,"footer-cast.php"

put following code to call it.

<?php get_footer('cast'); ?>



For more Interesting, Useful Article & codes visit IT New Code.
IT NEW CODE always help you with new Developing Code.

How to Disable auto formating?

IT NEW CODE give trick to disable auto formatting paragraph tag <p>.



To solve just like auto <p> tag generation problem add following code in your theme "function.php" file.

<?php

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

?>



For more Interesting, Useful Article & codes visit IT New Code.
IT NEW CODE always help you with new Developing Code.


Thursday 3 November 2016

How to Disable Ctrl+U?

Sometimes to protect our website content from copy-paste & miss use of it or protect it from spam uses need some security. To check the code of webpage "Ctrl+U" is use.
Below is given method to stop this code by script.
Simply Add this code.

Here Script is stop "Ctrl+U" by key code.
Just put following code in Header section <head> tag.


<!--------- Put this code in "<head>" tag ------------->

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
document.onkeydown = function(e) {
        if (e.ctrlKey &&
            (e.keyCode === 67 ||
             e.keyCode === 86 ||
             e.keyCode === 85 ||
             e.keyCode === 117)) {
            return false;
        } else {
            return true;
        }
};
$(document).keypress("u",function(e) {
  if(e.ctrlKey)
  {
return false;
}
else
{
return true;
}
});
</script>


For more Interesting, Useful Article & codes visit IT New Code.

 

Copyright @ 2016 IT New Code | Developing Code | Designing Code.

Designed by: Ankit Shah