Monthly archive for January 2010

Removing The Title Attribute From wp_list_categories & wp_list_pages

January 23, 2010 | Filed Under Wordpress | 4 Comments

Use  Exact Below code for  categories  and pages.

wp_list_categories:

<?php $title_free_cats = wp_list_categories(‘echo=0′);

$title_free_cats = preg_replace(‘/title=\”(.*?)\”/’,,$title_free_cats);

echo $title_free_cats; ?>


wp_list_pages:

<?php $title_free_pages = wp_list_pages(‘echo=0′); $title_free_pages = preg_replace(‘/title=\”(.*?) color: #000099; font-weight: bold;”>\”/’,,$title_free_pages); echo $title_free_pages; ?>

Article written by admin

Exclude category from RSS feed in wordpress

January 22, 2010 | Filed Under Wordpress | 3 Comments

To exclude category in wordpress rss feed.

you can simple write.

<a href="<?php bloginfo('url');  ?>/feed?cat=-1&cat=-2">(RSS)</a>

or   you can simple write below code in your theme function.php
to   exclude category categories.


function excludeCat($query) {
 if ($query->is_feed) {
 $query->set('cat','-1');// for   multiple use with , eg-  -1,-2,-3
 }
return $query;
 }
add_filter('pre_get_posts','excludeCat');
Article written by admin

Enable session in wordpress

January 22, 2010 | Filed Under Wordpress | Comments Off

wordpress does not provide the facility to enable session into wordpress.
but for enable session in wordpress you need to add

add_action(‘init’,’sessionStart’));

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

code in your theme  function.php.

But you must installed exec-php plugin to enable php code.

Article written by admin

How we can apply css in multiple Selectors in jquery.

January 20, 2010 | Filed Under JQuery | Comments Off

Here  to take effect is example to demonstrate

$(“div,span,p.myClass”).css(“border”,”1px solid green”);

the border will be apply in all div,span ,p.myClass class element.

Article written by admin

How we can modify the css class in jquery.

January 20, 2010 | Filed Under JQuery | Comments Off

Using css method we can modify class using jquery

example:$(“.CssClass1.CssClass2″).css(“border”,”1px solid green”);

CssClass1,CssClass2 will be modify to border  1px solid green.

Article written by admin

How can we apply css in div using jquery.

January 20, 2010 | Filed Under JQuery | Comments Off

using css() method we can apply css in div element.
example:
$(“div”).css(“border”,”1px solid green”);

Article written by admin

get the value of selected option in jquery

January 20, 2010 | Filed Under JQuery | Comments Off

suppose that below is  the  selectbox/combobox

<select id="sel">
   <option   value  ="1">Hi</option>
   <option value="2">Hello</option>
   <option value="3">Helloooooo</option>
   <option value="4">ok</option>
   <option value="5">Okey</option>
 </select>

want to get  the  value of selected option, then use
   $("select#sel").val();

or text of selected box, then use
$("#seloption:selected").text();

Example
Article written by admin

check/uncheck an input in jquery?

January 20, 2010 | Filed Under JQuery | Comments Off

Using two function, we can perform the operation.

// Check #x
$(“#checkboxid”).attr(“checked”, “checked”);
// Uncheck #x
$(“#checkboxid”).removeAttr(“checked”);

Example

Article written by admin

disable/enable an element in jquery?

January 20, 2010 | Filed Under JQuery | Comments Off

you can disable/enable web element using attr and removeAttr functions respectively

// Disable #x
$(“#x”).attr(“disabled”,”disabled”);
// Enable #x
$(“#x”).removeAttr(“disabled”);

Example:

type=”button” value=”Disable” onclick=”$(‘#x’).attr(‘disabled’,'disabled’)”/>

Article written by admin

How do I determine the state of a toggled element?

January 20, 2010 | Filed Under JQuery | Comments Off

Here is the example of toggled element using the  :visible or :hidden selectors.

var vis = $(‘#formdiv’).is(‘:visible’);
var hide= $(‘#formdiv’).is(‘:hidden’);
If you want to show a div visibility,  then there is example for this
For example:

$(‘#formdiv:visible’).animate({left: ‘+=100px’}, ‘slow’);

Article written by admin

How do I test whether an element exists?

January 19, 2010 | Filed Under JQuery | Comments Off

* You can use the length property of the jQuery collection returned by your selector: should i take

if ( $(‘#myDiv’).length)
$(‘#myDiv’).show();

Note: It isn’t always necessary to test whether an element exists.The following code would show the item if it exists, and do nothing (no errors) if  it did not:

$(‘#myDiv’).show();

Article written by admin

How do I test whether an element has a particular class?

January 19, 2010 | Filed Under JQuery | Comments Off

* You can use the is() method along with an appropriate selector

if ( $(‘#myDiv’).is(‘.pretty’) )
$(‘#myDiv’).show();

Note that this method allows you to  test for other things as well. For example, you can test whether an element is hidden (by using the custom :hidden selector):

if ( $(‘#myDiv’).is(‘:hidden’) )
$(‘#myDiv’).show();

* Note  also that hasClass has been added as of version 1.2 to handle the most common use of is():

$(“div”).click(function(){
if ( $(this).hasClass(“protected”) )
$(this)
.animate({ left: -10 })
.animate({ left: 10 })
.animate({ left: -10 })
.animate({ left: 10 })
.animate({ left: 0 });
});

Article written by admin

WordPress Installation Guide.

January 17, 2010 | Filed Under PHP | Comments Off

To instilled wordpress on your site is very simple
If you are non technical person don’t worry, you can also install wordpress.

By follow 5 steps

1-Download wordpress and Unzip wordpress
2-Create a Database
3-Create a wp_config.php file from wp-config-sample.php
4-Upload wordpress filse on your server
5-Open wordpress folder via Browser

1-Download wordpress and Unzip wordpress

Download wordpress from http://wordpress.org/download/

And unzip the zip file via zip/unzip software or use default unzip program

After unzip you will be get wordpress folder like below

2-Create a Database for WordPress

In second step you need to create a database on your server.

To connect to database wordpress require some detail

Like
Database Name (Which you have created for word press)
Server Name (In which server data base has created)
User Name (User name to access data base)
Password (Password to access data base)

When you will create database from your server administration area and assign user then you will get above details.

If you are working on localhost.

Then simple create database from php phpmyadmin or other interface

Note:You don’t need to add any table in the database, wordpress will automatically add tables.

3-Create a wp_config.php file from wp-config-sample.php
This file contain database information .so we need to create a file name wp-config.php

To create a wp_config.php file, simple copy of all codes wp-config-sample.php and paste on other emplty file and save as wp_config.php or rename wp-config-sample.php to wp_config.php


Then you will see wp_config.php like below

Here you need to add valid details of database.

define(‘DB_NAME’, ‘putyourdbnamehere’);

/** MySQL database username */
define(‘DB_USER’, ‘usernamehere’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘yourpasswordhere’);

/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);

You need to change only above information.

If you are working on localhost , you need to replace define(‘DB_PASSWORD’, ‘yourpasswordhere’); to define(‘DB_PASSWORD’, ‘’);
And define(‘DB_USER’, ‘usernamehere’); to define(‘DB_USER’, ‘root’);

4-Upload wordpress filse on your server

In forth step you need to upload all wordpress file on your server
Via FTP or Control panel. its depend on you.
For FTP, You need to have any file uploader software. Like filezilla.
Download from here

http://filezilla-project.org/download.php

5-Open wordpress folder via Browser
After uploading all files on server. You need to open your site on browser.
If wordpress files are in root.
Then write URL http://www.domainname.com
Or if wordpress files are in a folder name, blog in the root, for this you need to write URL

http://www.domainname.com/blog/

after open URL, you will automatically see below window

Write your blog title and Your E-mail address and click on Install WordPress Button.

Please remember username/password .
Your blog username and password will also mail to your email address.
After click on login button you will see next screen

Congratulation, you have been successfully installed wordpress.
Now you can log in and start setting up your blog!

Article written by admin

Differences between DROP and TRUNCATE a table?

January 15, 2010 | Filed Under MySQL | Comments Off

DROP TABLE table_name – This will delete the table and its data.

TRUNCATE  TABLE table_name – This will delete the data of the  trial offer table, but not the table definition.

Article written by admin

How many tables present in MySQL

January 15, 2010 | Filed Under PHP | Comments Off

Total 5 types of tables we can create
1. MyISAM
2.  Heap
3. Merge
4. INNO DB
5. ISAM

MyISAM is the default storage as of MySQL 3.23. When you fire the above create query MySQL will create a MyISAM table.

Article written by admin

what is difference between “$a dollars” or “{$a} dollars” ?

January 15, 2010 | Filed Under PHP | Comments Off

Best way to understand the problem is example.

<?php

$a=’Hello’;

Echo “$aworld” // blank because it treat as variable

Echo “{$a}world” // Helloworld

?>

Article written by admin

what is __toString magic function in php?

January 10, 2010 | Filed Under PHP | Comments Off

The __toString method allows a class to decide how it will react when it is converted to a string.

style="color: #000000;"><?php
// Declare a simple class
class TestClass
{
public
$foo;

public function __construct($foo) {
$this->foo = $foo;
}

public function __toString style=”color: #007700;”>() {
return
$this->foo;
}
}

$class = new TestClass(‘Hello’);
echo
$class;
?>

The above example will output:

Hello
Article written by admin

Magic Functions in php?

January 10, 2010 | Filed Under PHP | Comments Off

These are functions in PHP.

1__construct

2-__destruct (see Constructors and Destructors),

3-__call

4-__get

3-__set

4-__isset

5-__unset (see Overloading)

6-__wakeup

7-__toString

8-__set_state

9-__clone

Article written by admin

What’s __sleep and __wakeup in PHP?

January 10, 2010 | Filed Under PHP | Comments Off

These are  the magic function in php.
__sleep
serialize() checks if your class has a function with the magic name __sleep. If so, that function is executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. If the method doesn’t return anything then NULL is serialized and E_NOTICE is issued.
__wakeup
Conversely, unserialize() checks for the presence of a function with the magic name __wakeup. If present, this function can reconstruct any resources that the object may have.

server = $server;
$this->username = $username;
$this->password = $password;
$this->db = $db;
$this->connect();
}

private function connect()
{
$this->link = mysql_connect($this->server, $this->username, $this->password);
mysql_select_db($this->db, $this->link);
}

public function __sleep()
{
return array(‘server’, ‘username’, ‘password’, ‘db’);
}

public function __wakeup()
{
$this->connect();
}
}
?>

Article written by admin

How do you call a constructor for a parent class?

January 10, 2010 | Filed Under PHP | Comments Off

parent::constructor($value)

Article written by admin

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker