Friday, August 29, 2014

How to remove "Private" text from private posts?

function the_title_trim($title) {
$title = attribute_escape($title);
$findthese = array(
'#Protected:#',
'#Private:#'
);
$replacewith = array(
'', // What to replace "Protected:" with
'' // What to replace "Private:" with
);
$title = preg_replace($findthese, $replacewith, $title);
return $title;
}
add_filter('the_title', 'the_title_trim');

Monday, August 25, 2014

How to use custom font in wordpress?

Using non-standard fonts inside WordPress requires two additional steps:
  1. downloading and installing the font
  2. calling the font using @font-face


The CSS selector @font-face allows you to add support for custom fonts by including the font file in your CSS file. To add custom support for nearly any custom font, type the following into your site’s main style.css file:

 
 
 
@font-face{
font-family:karate;
src:url('/www/wp-content/themes/thesis-bp-child/custom-1/fonts/Karate.ttf') format ("truetype");
}


Simply input the name of the new font you’ve uploaded within the font-family selector like this:
 
 
 
#site-title a {font-family:karate;}

How to create an custom page Template?

To create a custom page template make a new file starting with a Template Name inside a PHP comment.

Here's the syntax:

<?php
/*
Template Name: My Custom Page
*/
 ?>
 
Once you upload the file to your Theme's folder, 
the template name, "My Custom Page", will list in the Edit Page screen's Template dropdown. 

Saturday, August 23, 2014

How to create an child theme?

In this example, we’re going to create a child theme for the Twenty Thirteen default WordPress theme.
(These steps can be done for any theme available on internet or if you create a custom them.)

1. The first thing we need to do is create a new folder in our themes directory to hold the child theme.

The themes directory is wp-content/themes for local users i.e. using wamp or xampp(You can do with using cPanel or via FTP for online sites). 

It’s important to name the folder without any space in the name, and it’s common practive to use the name of the parent theme folder with -child added on the end.

So for this example, we’ll be calling our folder “twentythirteen-child”.

2. In the child theme folder, create a file called style.css. This is the only file required to make a child theme.

The style sheet must start with the following lines:

/*
Theme Name: Twenty Thirteen Child
Theme URI: http://wordpress.org/themes/twentythirteen
Description: Twenty Thirteen Child Theme
Author: WPMU
Author URI: http://wpmu.com
Template: twentythirteen
Version: 1.0.0
*/
@import url("../twentythirteen/style.css");
/* =Theme customization starts here
-------------------------------------------------------------- */

Disable Ctrl Key, Right click and F12

<script language="JavaScript">

//////////F12 disable code////////////////////////
    document.onkeypress = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
           //alert('No F-12');
            return false;
        }
    }
    document.onmousedown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            //alert('No F-keys');
            return false;
        }
    }
document.onkeydown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            //alert('No F-keys');
            return false;
        }
    }
/////////////////////end///////////////////////


//Disable right click script
var message="Sorry, right-click has been disabled";

function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
//
function disableCtrlKeyCombination(e)
{
//list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'v', 'j' , 'w');
var key;
var isCtrl;
if(window.event)
{
key = window.event.keyCode;     //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{
key = e.which;     //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{
for(i=0; i<forbiddenKeys.length; i++)
{
//case-insensitive comparation
if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
{
//alert('Key combination CTRL + '+String.fromCharCode(key) +' has been disabled.');
return false;
}
}
}
return true;
}
</script>
</head>
<body onkeypress="return disableCtrlKeyCombination(event);" onkeydown="return disableCtrlKeyCombination(event);">
Press ctrl and you can check various key is disable with CTRL. like  — 'a', 'n', 'c', 'x', 'v', 'j' , 'w' Just add key in above the array and disable key as you want.
</body>
</html> 

Monday, August 18, 2014

How do I link a CSS file to my page?

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

How to add a custom widget area in WordPress

First you’ll want to add this code to your active theme’s function.php file. This code is used to register the custom widget area and create it on the backend.





// Custom widget area.
 register_sidebar( array(
    'name' => __( 'Custom Widget Area'),
    'id' => 'custom-widget-area',
    'description' => __( 'An optional custom widget area for your site', 'twentyten' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => "</li>",
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
) );

In above code you can give your own id and own name.
 
While creating multiple widget area you should keep the id different for each one.


Next you want to add this code to whichever page template you’d like the widget area to show on. This code is used to display the custom widget area in any location you choose within your theme’s files.






<?php
// Custom widget area start
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Custom Widget Area') ) : ?>
<?php endif; ?>

Saturday, August 02, 2014

URL Encoded Characters

 backspace      %08
      tab            %09
      linefeed       %0A
      creturn        %0D
      space          %20
      !              %21
      "              %22
      #              %23
      $              %24
      %              %25
      &              %26
      '              %27
      (              %28
      )              %29
      *              %2A
      +              %2B
      ,              %2C
      -              %2D
      .              %2E
      /              %2F
      0              %30
      1              %31
      2              %32
      3              %33
      4              %34
      5              %35
      6              %36
      7              %37
      8              %38
      9              %39
      :              %3A
      ;              %3B
      <              %3C
      =              %3D
      >              %3E
      ?              %3F
      @              %40
      A              %41
      B              %42
      C              %43
      D              %44
      E              %45
      F              %46
      G              %47
      H              %48
      I              %49
      J              %4A
      K              %4B
      L              %4C
      M              %4D
      N              %4E
      O              %4F
      P              %50
      Q              %51
      R              %52
      S              %53
      T              %54
      U              %55
      V              %56
      W              %57
      X              %58
      Y              %59
      Z              %5A
      [              %5B
      \              %5C
      ]              %5D
      ^              %5E
      _              %5F
      `              %60
      a              %61
      b              %62
      c              %63
      d              %64
      e              %65
      f              %66
      g              %67
      h              %68
      i              %69
      j              %6A
      k              %6B
      l              %6C
      m              %6D
      n              %6E
      o              %6F
      p              %70
      q              %71
      r              %72
      s              %73
      t              %74
      u              %75
      v              %76
      w              %77
      x              %78
      y              %79
      z              %7A
      {              %7B
      |              %7C
      }              %7D
      ~              %7E
      ¢              %A2
      £              %A3
      ¥              %A5
      |              %A6
      §              %A7
      «              %AB
      ¬              %AC
      ¯              %AD
      º              %B0
      ±              %B1
      ª              %B2
      ,              %B4
      µ              %B5
      »              %BB
      ¼              %BC
      ½              %BD
      ¿              %BF
      À              %C0
      Á              %C1
      Â              %C2
      Ã              %C3
      Ä              %C4
      Å              %C5
      Æ              %C6
      Ç              %C7
      È              %C8
      É              %C9
      Ê              %CA
      Ë              %CB
      Ì              %CC
      Í              %CD
      Î              %CE
      Ï              %CF
      Ð              %D0
      Ñ              %D1
      Ò              %D2
      Ó              %D3
      Ô              %D4
      Õ              %D5
      Ö              %D6
      Ø              %D8
      Ù              %D9
      Ú              %DA
      Û              %DB
      Ü              %DC
      Ý              %DD
      Þ              %DE
      ß              %DF
      à              %E0
      á              %E1
      â              %E2
      ã              %E3
      ä              %E4
      å              %E5
      æ              %E6
      ç              %E7
      è              %E8
      é              %E9
      ê              %EA
      ë              %EB
      ì              %EC
      í              %ED
      î              %EE
      ï              %EF
      ð              %F0
      ñ              %F1
      ò              %F2
      ó              %F3
      ô              %F4
      õ              %F5
      ö              %F6
      ÷              %F7
      ø              %F8
      ù              %F9
      ú              %FA
      û              %FB
      ü              %FC
      ý              %FD
      þ              %FE
      ÿ              %FF