Author Archives: prasad k

About prasad k

i m php developer, web designer.

How to Make Sticky Bar in WordPress Thesis Theme

All visible things in webpage will be disappear, when we scroll down. Sticky bar in a webpage will stick to the webpage and fixed in a constant position. Here is the tutorial for how to Make Sticky Bar in WordPress Thesis Theme. In this sticky bar, it will have blog name, facebook like, google + button, search bar and go to top button. This bar will stick to the top of the webpage. This sticky bar will make user interface much better and user can easily navigate to home page.

 

Sticky Bar in WordPress Thesis Theme

Sticky Bar in WordPress Thesis Theme

 

Step 1: Wordpress Admin -> Thesis(Left Menu bar) -> Skin Edior -> HTML Editor

Step 2: Add Textbox and give name as “sticky”

Step 3: WordPress Admin -> Thesis(Left Menu bar) -> Skin Content

Step 4: Put the following code in “sticky” textbox

Sticky – Text Box

[code type=html]
<div id=”sticky_outer”>
<div id=”sticky_inner”>
<ul id=”stickyleft”>
<li class=”logo”><a href=”/blog/#top”>Freeze Coders</a></li>

<li class=”fb”>
<div><iframe src=”http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Ffreezecoders&amp;send=false&amp;layout=button_count&amp;width=85&amp;show_faces=false&amp;action=like&amp;colorscheme=dark&amp;font&amp;height=21″ style=”border:none; overflow:hidden; width:85px; height:21px; margin-left:38px” allowtransparency=”true” frameborder=”0″ scrolling=”no”></iframe></div>
</li>

<li class=”gplus1″>
<script type=”text/javascript” src=”https://apis.google.com/js/plusone.js”></script>
<div class=”gplus”>
<g:plusone size=”medium” annotation=”none” href=”http://www.freezecoders.com/”></g:plusone>
</div>
</li>
</ul>

<ul id=”stickyRight”>
<li class=”searchbox”>
<form method=”get” action=”http://www.XXXX.com/?s=”><p>
<input class=”sticky_input” type=”text” value=”Text to Search” name=”s” id=”s” onfocus=”if (this.value == ‘Text to Search’) {this.value = ”;}” onblur=”if (this.value == ”) {this.value = ‘Text to Search’;}” />
</p>
</form>
</li>

<li class=”btt”><a href=”#top” title=”Back to top”>↑</a></li>
</ul>
</div>
</div>

[/code]

 

Step 5: WordPress Admin -> Thesis -> Custom CSS and Put the following code

Custom CSS

[code type=html]

#sticky_outer {
position: fixed;
z-index: 2;
top: -110px;
width: 100%;
height: 45px;
line-height: 45px;
color: rgb(255, 255, 255);
border-top: 1px solid rgb(72, 72, 72);
border-bottom: 2px solid rgb(0, 0, 0);
background: #000;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.6);
}
#sticky_inner {
width: 970px;
margin: 0px auto;
}
#stickyleft {
float: left;
width: 68%;
}
.sticky_input
{
padding: 5px 10px;
border-radius: 19px;
border: 1px solid #000;
color: #C5C5C5;
outline: 0px;
box-shadow: inset 1px 1px 4px #6D6D6D;
-moz-box-shadow: inset 1px 1px 4px #6D6D6D;
-webkit-box-shadow: inset 1px 1px 4px #6D6D6D;
-o-box-shadow: inset 1px 1px 4px #6D6D6D;
-ms-box-shadow: inset 1px 1px 4px #6D6D6D;
}
#stickyRight {
float: left;
width: 25%;
}
#stickyleft li {
margin-right: 1%;
}
#sticky_inner li {
list-style: none outside none;
float: left;
}

#stickyleft .logo a {
width: 225px;
color: rgb(255, 255, 255);
font-family: “Droid Sans”,Helvetica,Arial,sans-serif;
font-weight: bold;
text-transform: uppercase;
display: block;
height: 35px;
}
.fb
{
margin: 11px 0 0 0;
}
.gplus1
{
margin: 2px 0 0 0;
}
.btt a
{
display: block;
color: rgb(204, 204, 204);
margin: 9px 0px 0px 20px;
background: none repeat scroll 0% 0% rgb(255, 255, 255);
padding: 0px 11px;
border-radius: 55px;
height: 29px;
line-height: 25px;
}

[/code]

 

Step 6: WordPress Admin -> Thesis -> Manage Boxes -> HTML Head Editor -> Head Scripts

Place the following code

[code type=html]

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js”>
</script>
<script type=”text/javascript”>
$(function(){
var listval = $(‘#sticky_outer’)[0].offsetTop;
$(document).scroll(function() {
var topval = $(document).scrollTop();
if(topval >= 130){
$(‘#sticky_outer’).css(‘top’,’0px’);
} else {
$(‘#sticky_outer’).css(‘top’,’-110px’);
}
});
});
</script>

[/code]

 

 

How to make Simple Responsive Website Design Using CSS3 Media Query

Responsive Webpage is the webpage design, which will automatically resize based on screen resolution. Responsive webpage design will ensure the user interface. Responsive webpage design can be done in many ways like media query, bootstrap design, jquery, etc. Here is the tutorial for how to make simple responsive website design Using CSS3 media query.

 

 

HTML CODE (index.php)

[code type=html]

<html>
<head>
<link rel=”stylesheet” href=”style.css” type=”text/css”>
</head>

<body>
<div class=”header”>
<div class=”container”>
<div class=”logo”>
Logo
</div>
</div>
</div>
<!– end of header–>

<div class=”container”>
<div class=”content”>
Audience and Device Aware is an approach aimed at ensuring that a site is
optimised to deliver what a user wants and that works effectively on the
device being used to access the site. Unlike Responsive web design (RWD),
which crafts a site visually for a range of devices, ADA aims to reflect
the many different elements that enhance and impact on the performance and
usability of a site. The predominant application for the ADA approach is
for mobile and smaller screen devices. The principle truly sees the adoption
of a “mobile first” strategy and focuses on the performance of a site and
value that it delivers to a user and the business. Mobile first, unobtrusive
JavaScript, and progressive enhancement “Mobile first”, unobtrusive
JavaScript, and progressive enhancement (strategies for when a new
site design is being considered) are related concepts that predated RWD:
browsers of basic mobile phones
</div>
<!– end of content–>

<div class=”sidebar”>
<div class=”sidebar-title”>Sidebar</div>
<ul>
<li><a href=”#”>Sidebar 1</a></li>
<li><a href=”#”>Sidebar 2</a></li>
<li><a href=”#”>Sidebar 3</a></li>
<li><a href=”#”>Sidebar 4</a></li>
<li><a href=”#”>Sidebar 5</a></li>
</ul>
</div>
<!– end of sidebar–>

</div>
<!– end of container –>

</body>
</html>

[/code]

CSS CODE (style.css)

CSS, which are used inside the tag @media all and (max-width: 1000px) will be triggered when the window resolution is below 1000px

[code type=css]

.header
{
height: 150px;
background: #FC3;
margin: -8px -8px 8px -8px;
}
.logo
{
font-size: 36px;
color: #333;
padding: 20px;
}
.container
{
width: 1000px;
margin: 0 auto;
}
.content
{
width: 672px;
float: left;
margin: 0 5px 0 0;
padding: 4px;
background: #E9E9E9;
color: #363636;
}
.sidebar
{
width: 300px;
float: left;
background: #5FA882;
}
.sidebar-title
{
font-size: 28px;
text-transform: uppercase;
margin: 10px;
}

.sidebar ul
{
padding: 0;
margin: 0;
}
.sidebar li
{
display:block;
}
.sidebar li a
{
text-decoration: none;
display: block;
padding: 5px 3px;
margin: 10px;
background: #FAFAFA;
color: #000;
}

/* Media query for responsive*/
@media all and (max-width: 1000px) {
.container, .content
{
width: 100%;
}
.sidebar
{
width: 100%;
margin: 10px 0 0 0;
}
.sidebar-title
{
text-align:center;
}
}
[/code]

How to use Custom jQuery Code in WordPress Thesis

Default option is available in thesis to include jquery library files and add custom jquery. Here is the tutorial about how to use Custom jQuery Code in WordPress Thesis theme. Under Head Script option, we can use our jquery codes.

STEP 1: WordPress Admin -> Thesis -> Manage Boxes -> HTML Head Editor

STEP 2: Place the following code inside the HTML Head Editor

  • First script included is jquery library file from google.
  • Second script is our custom jquery code.

[code type=html]
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js”>
</script>

<script type=”text/javascript”>
$(function(){

/* YOUR CODE*/

alert(‘Custom jquery Code has been executed’);
});
</script>
[/code]

Above javascript will bring an alert box,  when page refreshes

 

 

Add Floating Social Media Buttons in WordPress Thesis without Plugin

Floating social media share icons on floating style will bring more attraction on it. Here is the tutorial for how to add Floating Facebook Like, Tweet and Google+ in WordPress Thesis without Plugin.

This floating bar won’t display on home, category and archive page. Floating Social share bar will be displayed only on post page, that is single page.

 

Floating Bar

Floating Bar

Step 1: WordPress Admin -> Thesis (Left side) -> Skin Editor -> HTML Editor

Step 2: Click on Container, which is having columns and sidebar. Then give Hook Name as “floating”

Step 3: Directory -> wp-content ->thesis -> skins -> YOUR SKIN -> custom.php

I am using default “classic-r” skin, so directory path for me is Directory -> wp-content ->thesis -> skins -> classic-r -> custom.php

Step 4: Place the code in custom.php file

  • if(is_single()) – this condition will check is this page single page or category page.
  • get_permalink($post->ID) – this function will return the current post/article URL
  • get_the_title($post->ID) – this function will return current post/article title
Custom.php Code

[code type=php]

function float() {
if(is_single())
{
?>

<div id=”floating-box”>

<div class=”twitter”><a href=”https://twitter.com/share” class=”twitter-share-button” data-url=”<?php echo get_permalink($post->ID); ?>” data-text=”<?php echo get_the_title($post->ID); ?>” data-count=”vertical”>Tweet</a></div>

<div class=”google”>
<g:plusone href=”<?php echo urlencode(get_permalink($post->ID)); ?>” size=”tall”></g:plusone>
</div>

<div class=”facebook”>
<iframe src=”http://www.facebook.com/plugins/like.php?href=<?php echo get_permalink($post->ID); ?>&amp;width=300&amp;height=258&amp;colorscheme=light&amp;layout=box_count&show_faces=true&amp;border_color=%23ffffff&amp;stream=false&amp;header=false” scrolling=”no” frameborder=”0″ style=”border: none; overflow: hidden; width: 300px; height: 61px; display: inline; margin: 0 0 0 -2px;” allowtransparency=”true”></iframe>
</div>

<div class=”pin”>
<a href=”http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>” class=”pin-it-button” count-layout=”vertical”>Pin It</a>
</div>
</div>
<?php
}
}

add_action(‘hook_after_floating’,’float’);

[/code]

 

Step 5:  WordPress Admin -> Thesis (Left side) -> Custom CSS

Custom CSS

[code type=css]

#floating-box{
border: 1px solid #DDD;
background: #FFF;
float: left;
margin: 0 0 0 -95px;
padding: 2px;
position: fixed;
top: 255px;
z-index: 1;
width: 65px;
}

[/code]

How to make Full Width Navigation/Menu Bar in Thesis

Default thesis skin will comes with a fixed header and menu/navigation bar. Here is the way how to make full width menu in thesis framework. Full width navigation bar can also be done with custom php code, here we are going to have a full width header with thesis editor in simple way.

This is the default navigation bar style

 

Navigation menu Thesis

Navigation menu Thesis

 

Step 1:   Go to WordPress Admin Panel -> Thesis -> Skin Editor

Step 2:  Choose “HTML Container” box

add html container - full width navigation menu bar thesis

add html container

 

Step 3:  Add “Container” box just below the HTML BODY

Step 4:  Click Box options of newly added container, give name as “Head Container” and class as “container”

Name&Class-- full width navigation menu bar thesis

full width navigation menu bar thesis

 

Step 5: Move Header box from container to “Head Container”

 

Step 6:  Add new container box, just below the “Head Container”. Give name as “Full Width Menu” and class as “full-width-menu”

Full width navigation menu bar thesis

Full width navigation menu bar thesis

 

Step 7:  Add new container box inside the “Full Width Menu”. Give class as “container”

Full width navigation menu bar thesis

Full width navigation menu bar thesis

 

Step 8:  Move “Nav Menu” from container to “Full width Menu” box

Nav Menu from container to Full width Menu

Nav Menu from container to Full width Menu

 

Step 9:   Go to WordPress Admin Panel -> Thesis -> Custom CSS

then add the following css code

[code type=css]
.full-width-header
{
background: #D83434;
}
[/code]

 

Step 10:   Go to WordPress Admin Panel -> Thesis -> Skin Editor

Add the following css code to .menu a

[code type=css]
.menu a
{
background: #D83434;
color: #FFF;
}
[/code]

 

Final Result

Final look Full width navigation menu bar thesis

Final look Full width navigation menu bar thesis

How to make Full Width Header in Thesis

Default thesis skin will comes with a fixed header. Here is the way how to make full width header in thesis framework. Full width header will gives the website pleasant look. Full width header can also be done with custom php code, here we are going to have a full width header with thesis editor.

This is the default header style

Default header in thesis theme - Full Width Header Thesis

Default header in thesis theme – Full Width Header Thesis

 

Step 1:   Go to WordPress Admin Panel -> Thesis -> Skin Editor

Step 2:  Choose “HTML Container” box

Add Container box -- Full Width Header Thesis

Add Container box — Full Width Header Thesis

 

 Step 3:  Add “Container” box just below the HTML Body.

Add Container box - Full Width Header Thesis

Add Container box – Full Width Header Thesis

 

Step 4: Click on the “Show box options” button on newly added “Container” box.

Click show box - Full Width Header Thesis

Click show box – Full Width Header Thesis

 

Step 5: Change name of  “Container” box as “Full Width Header” and give class name as “full-width-header”

Full Width Container box options - Full Width Header Thesis

Full Width Container box options – Full Width Header Thesis

 

Step 6:   Go to WordPress Admin Panel -> Thesis -> Custom CSS

then add the following css code

[code type=css]

.full-width-header

{

background: #F82A2A;

}

[/code]

 

Step 7:   Add new HTML Container box into “Full Width Header” box

Add Container - Full Width Header Thesis

Add Container – Full Width Header Thesis

 

Step 8  Click on “Show box options” button and give class name as “container”

Container Property

Container Property

 

Step 9  Just Drag and drop the “Header” box and “Nav Menu” box from below container into the Full Width Header box’s container

move header navmenu to full width header
move header navmenu to full width header

 

Step 10:  Here is the thesis header in full width

Thesis header in full width header

Thesis header in full width header

 

 

 

Disable Selection of Particular area using CSS3 Property user-select

CSS3 allows to disable the selection of particular area using user-select property. This property will be useful in websites, which doesn’t wants user to copy particular content by selection. We can copy the unselectable area by other means, but its a primary step to disable particular area selection.

 

User-select CSS3 Code

[code type=css]
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
[/code]

 

Demo

Select Here….Select Here….Select Here….Select Here….Select Here….

 
 

Category: CSS

5 PHP Functions for Words Formatting

PHP functions are used for text formatting. Formatting like uppercase, lowercase and first letter uppercase can also be done using php functions, here is the 5 php functions for words/text formatting

  • ucwords
  • strtoupper
  • strtolower
  • ucfirst
  • lcfirst

 

ucwords()

Make each word’s first letter as capital letter

[code type=php]

$text = “freeze coders”;

$text1 = ucwords($text); // Output –  Freeze Coders

[/code]

 

strtoupper()

strtoupper php function will make all words as upper case(capital letter)

[code type=php]

$text = “freeze coders”;

$text1 = strtoupper($text); // Output –  FREEZE CODERS

[/code]

 

strtolower()

strtolower php function will make all words as lower case(capital letter)

[code type=php]

$text = ” FREEZE CODERS”;

$text1 = strtolower($text); // Output –  freeze coders

[/code]

 

ucfirst()

ucfirst php function will make the first letter of a string as uppercase

[code type=php]

$text = “freeze coders”;

$text1 = ucfirst($text); // Output –  Freeze coders

[/code]

 

lcfirst()

lcfirst() php function will return the string’s first letter lowercase

[code type=php]

$text = ” FREEZE CODERS”;

$text1 = lcfirst($text); // Output –  fREEZE CODERS

[/code]

 

Category: PHP

Display Message on Post Preview Page in WordPress

WordPress having an option called Preview, while writing a post if we want to check the structure or alignment we can use preview option. Preview option is placed in Right Side of Edit Post Page. Here is the PHP code to display a message that you are in preview page.

 

 

is_preview()

is_preview() function will return the boolean value of true or false. If the page is preview, then it will return true else it will return false.

 

PHP Code

Include the below coding in header.php file just after the <body> tag

[code type=php]

<?php
if(is_preview())
{
echo “<div class=’preview-box’>This Page is Preview Page</div>”;
}
?>

[/code]

 

Stylesheet

Include the below coding in style.css file
[code type=css]
.preview-box
{
position: fixed;
bottom: 0px;
background: #E54324;
color: #fff;
width: 100%;
padding: 12px 0px;
font-weight: bold;
}
[/code]

 

After including this file in header.php and style.css file then alert message will be shown in bottom.

Display Message on Post Preview Page in WordPress

Display Message on Post Preview Page in WordPress

 

 

 

Store value from Dropdown in SESSION Using Ajax with Lightbox

Storing the value from dropdown box in session using ajax programming with lightbox means user will have only focus to dropdown box. Lightbox will be overlayed on website, so the dropdown box can easily get selected by user. Here is the tutorial, source code and demo link

 

 

 

 

Store value from Dropdown in SESSION Using Ajax with Lightbox

Store value from Dropdown in SESSION Using Ajax with Lightbox

 

jQuery & Ajax

This below jquery will get the height of browser

var height=$(window).height();
var width=$(window).width();

[code type=javascript]
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){

var height=$(window).height();
var width=$(window).width();
$(“.black-overlay”).css(“display”,”block”);
$(“.form-area”).css(“display”,”block”);
$(“.black-overlay”).css(“height”,height);
$(“.form-area”).css(“margin-top”,height/2);
$(“.form-area”).css(“margin-left”,width/2.6);

$(‘#city’).change(function(){
$(“.black-overlay”).css(“display”,”none”);
$(“.form-area”).css(“display”,”none”);
var area=$(‘#city option:selected’).val();
$.ajax({
type: “POST”,
url: “ajax.php”,
data: “area=”+area ,
success: function(html){
$(‘#area’).val(html);
}
});

});
});
</script>

[/code]

 

Stylesheet

[code type=css]

.black-overlay
{
background:#000;
opacity: 0.6;
position:fixed;
top: 0;
left: 0;
width: 100%;
z-index: 110000;
display:none;
}
.form-area
{
width: 300px;
margin:0 auto;
position: fixed;
z-index: 10000000;
display:none;
}
#city
{
padding: 7px 13px;
width: 226px;
height: 43px;
border: 1px solid #fff;
line-height: 50px;
font-size: 21px;
color: #000;
}
.select-city-text
{
color: #fff;
text-transform: uppercase;
font-family: verdana;
font-size: 20px;
margin: 0 0 8px 0;
letter-spacing: 9px;
}

[/code]

 

index.php

[code type=php]

<?php
session_start();
?>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){
var height=$(window).height();
var width=$(window).width();
$(“.black-overlay”).css(“display”,”block”);
$(“.form-area”).css(“display”,”block”);
$(“.black-overlay”).css(“height”,height);
$(“.form-area”).css(“margin-top”,height/2);
$(“.form-area”).css(“margin-left”,width/2.6);

$(‘#city’).change(function(){
$(“.black-overlay”).css(“display”,”none”);
$(“.form-area”).css(“display”,”none”);
var area=$(‘#city option:selected’).val();
$.ajax({
type: “POST”,
url: “ajax.php”,
data: “area=”+area ,
success: function(html){
$(‘#area’).val(html);
}
});
});
});
</script>
<style type=”text/css”>
.black-overlay
{
background:#000;
opacity: 0.6;
position:fixed;
top: 0;
left: 0;
width: 100%;
z-index: 110000;
display:none;
}
.form-area
{
width: 300px;
margin:0 auto;
position: fixed;
z-index: 10000000;
display:none;
}
#city
{
padding: 7px 13px;
width: 226px;
height: 43px;
border: 1px solid #fff;
line-height: 50px;
font-size: 21px;
color: #000;
}
.select-city-text
{
color: #fff;
text-transform: uppercase;
font-family: verdana;
font-size: 20px;
margin: 0 0 8px 0;
letter-spacing: 9px;
}
</style>

</head>

<body>
<div class=”black-overlay”>
</div>

<form method=”post” action=”” class=”form-area”>
<div class=”select-city-text”>Select City</div>
<select id=”city”>
<option>Bangalore</option><option>Mysore</option><option>Bagalkot</option><option>Bangalore</option><option>Basavakalyan</option><option>Belgaum</option><option>Bellary</option><option>Bhadravati</option><option>Bidar</option><option>Bijapur</option><option>Bommanahalli</option>
</select>
</form>
<input type=”text” id=”area” />
</body>
</html>

[/code]

ajax.php

Data passed to ajax.php will be stored in a SESSION
[code type=php]
session_start();
if(!empty($_POST[‘area’]))
{
$_SESSION[‘area’]=$_POST[‘area’];
echo $_SESSION[‘area’];
}
[/code]