How to use mongodb with php

If you want to use the mongodb with php then you need to install pecl libraries. Mongo extension is not bundled with PHP.

The MongoDB server is built to already work with your current web server. The problem is that you’ll need to install drivers for your preferred backend language – PHP, Ruby, Node.js, Perl, whatever.

How to use mongodb with php

How to use mongodb with php
How to use mongodb with php

For installing the Mongo use following URL:
If you dont have pecl installed on your linux machine then use following command.
# yum install php-pecl*
then use following command
# pecl install mongo
Then open the php.ini file. if you are using the linux then use following command.
# vim /etc/php.ini

## Add following lines, end of php.ini file ##
# MongoDB Driver
extension=mongo.so

Restart the apache webserver using following command
# /etc/init.d/httpd restart
If Mongodb server is running then use can test your mongodb database using following code:
Create the mongotest.php file

<!--?php
// connect
$m = new Mongo();
// select a database
$db = $m--->wordpress;
$collection = $db->wordpressapi;
// add an element
$obj = array( "title" => "Sony this Good.\n", "author" => "Wordpressapi.com" );
$collection->insert($obj);
// add another element, with a different "shape"
$obj = array( "title" => "Wordpressapi.com", "online" => true );
$collection->insert($obj);
// find everything in the collection
$cursor = $collection->find();
// iterate through the results
foreach ($cursor as $obj) {
echo $obj["title"] . "\n";
echo $obj["author"] . "\n";
}
// disconnect
$m->close();
?>

If you open this file in browser then you can see the following words in browser:
Sony this Good. WordPressapi.com Sony this Good. WordPressapi.com
If you want to use the mongodb with php then you need to install pecl libraries. Mongo extension is not bundled with PHP.
For installing the Mongo use following URL:
If you dont have pecl installed on your linux machine then use following command.# yum install php-pecl*
then use following command# pecl install mongo
Then open the php.ini file. if you are using the linux then use following command.
# vim /etc/php.ini

## Add following lines, end of php.ini file ### MongoDB Driverextension=mongo.so

Restart the apache webserver using following command
# /etc/init.d/httpd restart
If Mongodb server is running then use can test your mongodb database using following code:
Create the mongotest.php file

<!--?php
// connect$m = new Mongo();
// select a database$db = $m--->wordpress;$collection = $db->wordpressapi;
// add an element$obj = array( "title" => "Sony this Good.\n", "author" => "Wordpressapi.com" );$collection->insert($obj);
// add another element, with a different "shape"$obj = array( "title" => "Wordpressapi.com", "online" => true );$collection->insert($obj);
// find everything in the collection$cursor = $collection->find();
// iterate through the resultsforeach ($cursor as $obj) {    echo $obj["title"] . "\n";     echo $obj["author"] . "\n";}
// disconnect$m->close();
?>

If you open this file in browser then you can see the following words in browser:Sony this Good. WordPressapi.com Sony this Good. WordPressapi.com

How to install Mongodb on linux

Mongodb is used for many projects now, it is quite fast. I given full detailed information about How to install Mongodb on linux box. Before installing the Mongodb on linux box you need to install following packages on box.

How to install Mongodb on linux

[root@sonyk-pc Download]# sudo yum -y install git tcsh scons gcc-c++ glibc-devel
[root@sonyk-pc Download]# sudo yum -y install boost-devel pcre-devel js-devel readline-devel
[root@sonyk-pc Download]# sudo yum -y install boost-devel-static readline-static ncurses-static

For 32bit user use following command

[root@sonyk-pc Download]# wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz

For 64bit use following command

[root@sonyk-pc Download]# wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.6.2.tgz
[root@sonyk-pc Download]# tar xzf mongodb-linux-i686-1.6.2.tgz
[root@sonyk-pc Download]#  cd mongodb-linux-i686-1.6.2

Mongo stores database in data/db folder. so we need to create those folder using following command.

[root@sonyk-pc mongodb-linux-i686-1.6.2]# sudo mkdir -p /data/db/
[root@sonyk-pc mongodb-linux-i686-1.6.2]# sudo chown `id -u` /data/db
[root@sonyk-pc mongodb-linux-i686-1.6.2]# ./bin/mongod
./bin/mongod --help for help and startup options
Thu Sep  9 13:10:55 MongoDB starting : pid=22159 port=27017 dbpath=/data/db/ 32-bit
** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
**       see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Sep  9 13:10:55 db version v1.6.2, pdfile version 4.5

If you want to create mongodb service in linux then use following steps:

[root@sonyk-pc Download]# wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz
[root@sonyk-pc Download]# tar xzf http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz
[root@sonyk-pc Download]# mv mongodb-linux-i686-1.6.2 /opt/mongodb
[root@sonyk-pc Download]# mkdir -p /srv/db/mongodb
[root@sonyk-pc Download]# touch /srv/db/mongodb.log
[root@sonyk-pc Download]# mkdir /opt/bin/
[root@sonyk-pc Download]# mkdir /opt/config/

create the File: /opt/bin/mongodb-stop
Put following code in that file:

#!/bin/bash
pid=`ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'`;
if [ "${pid}" != "" ]; then
kill -2 ${pid};
fi

create the File: /opt/bin/mongodb-start
Put following code in that file:

#!/bin/sh
/opt/mongodb/bin/mongod --config /opt/config/mongodb \
## --upgrade \ ##runs a database upgrade option if needed \

File: /opt/config/mongodb
Put following code in that file:

# Configuration Options for MongoDB
#
# For More Information, Consider:
# - Configuration Parameters: http://www.mongodb.org/display/DOCS/Command+Line+Parameters
# - File Based Configuration: http://www.mongodb.org/display/DOCS/File+Based+Configuration
dbpath = /srv/db/mongodb
logpath = /srv/db/mongodb.log
logappend = true
bind_ip = 127.0.0.1
port = 27017
fork = true
auth = true
# noauth = true

Do that file as linux executable
chmod +x /opt/bin/mongodb-start
chmod +x /opt/bin/mongodb-stop
We’ve also created a very basic “init script” as a wrapper around the mongodb-start and mongo-stop scripts described above. You will still need to modify and manage the configuration of your MongoDB server in the files above. This script only provides a means for ensuring that MongoDB will start at boot. Issue the following commands:
wget http://library.linode.com/databases/mongodb/reference/init-rpm.sh
mv init-rpm.sh /etc/rc.d/init.d/mongodb
chmod +x /etc/rc.d/init.d/mongodb /etc/init.d/mongodb
chkconfig –add mongodb
chkconfig –level 35 mongodb on
You will also need to create a user and group for mongodb; issue the following command:

useradd -M -r --home-dir /opt/mongodb mongodb

Now issue the following command to ensure that the MongoDB user you just created will have access to all required files in the /srv/db/ hierarchy:
chown mongodb:mongodb -R /srv/db/
To start and stop MongoDB using the init script, issue the appropriate command from the following:
/etc/init.d/mongodb start
/etc/init.d/mongodb stop
For checking the web admin interface of Mongodb – listening on port 28017
Check this URL : http://localhost:28017/
Before installing the Mongodb on linux box you need to install following packages on box.[root@sonyk-pc Download]# sudo yum -y install git tcsh scons gcc-c++ glibc-devel[root@sonyk-pc Download]# sudo yum -y install boost-devel pcre-devel js-devel readline-devel[root@sonyk-pc Download]# sudo yum -y install boost-devel-static readline-static ncurses-static

For 32bit user use following command[root@sonyk-pc Download]# wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz
For 64bit use following command[root@sonyk-pc Download]# wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.6.2.tgz

[root@sonyk-pc Download]# tar xzf mongodb-linux-i686-1.6.2.tgz [root@sonyk-pc Download]# cd mongodb-linux-i686-1.6.2
Mongo stores database in data/db folder. so we need to create those folder using following command.
[root@sonyk-pc mongodb-linux-i686-1.6.2]# sudo mkdir -p /data/db/[root@sonyk-pc mongodb-linux-i686-1.6.2]# sudo chown `id -u` /data/db
Using following command you can start the mongo database.
[root@sonyk-pc mongodb-linux-i686-1.6.2]# ./bin/mongod./bin/mongod –help for help and startup optionsThu Sep 9 13:10:55 MongoDB starting : pid=22159 port=27017 dbpath=/data/db/ 32-bit
** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data** see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Sep 9 13:10:55 db version v1.6.2, pdfile version 4.5

If you want to create mongodb service in linux then use following steps:
[root@sonyk-pc Download]# wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz [root@sonyk-pc Download]# tar xzf http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz[root@sonyk-pc Download]# mv mongodb-linux-i686-1.6.2 /opt/mongodb[root@sonyk-pc Download]# mkdir -p /srv/db/mongodb[root@sonyk-pc Download]# touch /srv/db/mongodb.log
[root@sonyk-pc Download]# mkdir /opt/bin/[root@sonyk-pc Download]# mkdir /opt/config/
create the File: /opt/bin/mongodb-stopPut following code in that file;

#!/bin/bash
pid=`ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'`;if [ "${pid}" != "" ]; then    kill -2 ${pid};fi

create the File: /opt/bin/mongodb-startPut following code in that file:

#!/bin/sh
/opt/mongodb/bin/mongod --config /opt/config/mongodb \## --upgrade \ ##runs a database upgrade option if needed \

File: /opt/config/mongodbPut following code in that file:

# Configuration Options for MongoDB## For More Information, Consider:# - Configuration Parameters: http://www.mongodb.org/display/DOCS/Command+Line+Parameters# - File Based Configuration: http://www.mongodb.org/display/DOCS/File+Based+Configuration
dbpath = /srv/db/mongodblogpath = /srv/db/mongodb.loglogappend = true
bind_ip = 127.0.0.1port = 27017fork = true
auth = true# noauth = true

Do that file as linux executatblechmod +x /opt/bin/mongodb-startchmod +x /opt/bin/mongodb-stop

We’ve also created a very basic “init script” as a wrapper around the mongodb-start and mongo-stop scripts described above. You will still need to modify and manage the configuration of your MongoDB server in the files above. This script only provides a means for ensuring that MongoDB will start at boot. Issue the following commands:
wget http://library.linode.com/databases/mongodb/reference/init-rpm.shmv init-rpm.sh /etc/rc.d/init.d/mongodbchmod +x /etc/rc.d/init.d/mongodb /etc/init.d/mongodbchkconfig –add mongodbchkconfig –level 35 mongodb on

You will also need to create a user and group for mongodb; issue the following command:

useradd -M -r --home-dir /opt/mongodb mongodb

Now issue the following command to ensure that the MongoDB user you just created will have access to all required files in the /srv/db/ hierarchy:
chown mongodb:mongodb -R /srv/db/
To start and stop MongoDB using the init script, issue the appropriate command from the following:
/etc/init.d/mongodb start/etc/init.d/mongodb stop

For checking the web admin interface of Mongodb – listening on port 28017Check this URL : http://localhost:28017/

How to install Mongodb on linux
How to install Mongodb on linux

Post message to another server through fopen and fsockopen in php

PHP tutorial for, Post message to another server through fopen and fsockopen in php. When this comes to sending data to server to server we need to post the data using web services.
Many people want to use the curl php method but there are serious issues with that.

Post message to another server through fopen and fsockopen in php

 

Post message to another server through fopen and fsockopen in php
Post message to another server through fopen and fsockopen in php

So I recommended to use fopen function to post the message to server to server.

You can use the following code for post the message to another server using fopen and fsockopen

    function post($host, $post_url,$port,$data) {
        $errno = 0;
        $errstr = '';

        $path = str_replace($host,'',$post_url); // IP of minor instance

        $header_variables = "POST / HTTP/1.1\r\n";
        $header_variables .= "Host: $host\r\n";
        $header_variables .= "Connection: Close\r\n";
        $header_variables .= "Content-Type: application/xml\r\n";
        $header_variables .= "Content-Length: " . strlen($data) . "\r\n\r\n";

        // establish the connection and send the request
        $fp = fsockopen($host, $port, &$errno, &$errstr, 15);
        if ($fp) {
            stream_set_timeout($fp, 15);
            fputs($fp, $header_variables);
            fputs ($fp, $data); //data written
            fputs ($fp, "\r\n"); //request posted

            $response = stream_get_contents($fp);
            $info = stream_get_meta_data($fp);
            if (!$info['timed_out'] && $fp) {
                //get response and everything is ok
            } else {
                trigger_error('Timed out for '.$post_url);
                exit();
            }

            fclose($fp); //close the file

        } else {
            trigger_error('Failed to open socket connection. ');
            exit();
        }
    }



using CURL function post message also possible for that you can use following code

<!--?php

/* http://localhost/upload.php:
print_r($_POST);
print_r($_FILES);
*/

$ch = curl_init();

$data = array('name' =--> 'Foo', 'file' => '@/home/user/test.png');

curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec($ch);
?>

Remove author word from wordpress permalink

In wordpress some people wants to create the community site and they want to create uniqe url for each user. In that time you need to remove the author word from wordpress permalink. Normally when we want to see the author URL then you can see URL as follows.

Remove author word from wordpress permalink

Co-Authors Plus Remove author word from wordpress permalink
Co-Authors Plus Remove author word from wordpress permalink

http://website.com/author/username/

If you can want to change the url to following

http://website.com/username

then you just need to edit only .htaccess file. Put following line in that file

RewriteRule ^author/(.+)$ http://www.yourblog.com/$1 [R=301,L] // change yourblog to website name 

If you dont want to change the .htaccess file and still want to change the permalink structure then open the functions.php file from you wordpress theme folder.

add_filter('author_link', 'no_author_base', 1000, 2);
function no_author_base($link, $author_id) {
    $link_base = trailingslashit(get_option('home'));
    $link = preg_replace("|^{$link_base}author/|", '', $link);
    return $link_base . $link;
}
add_filter('author_rewrite_rules', 'no_author_base_rewrite_rules');
function no_author_base_rewrite_rules($author_rewrite) {
    global $wpdb;
    $author_rewrite = array();
    $authors = $wpdb->get_results("SELECT user_nicename AS nicename from $wpdb->users");
    foreach($authors as $author) {
        $author_rewrite["({$author->nicename})/page/?([0-9]+)/?$"] = 'index.php?author_name=$matches[1]&paged=$matches[2]';
        $author_rewrite["({$author->nicename})/?$"] = 'index.php?author_name=$matches[1]';
    }
    return $author_rewrite;
}

create install script for drupal module and create tables

Drupal is most popular CMS in the world for creating the web application. For custom purpose we need to create the drupal modules. We need the custom tables for creating the drupal.

create install script for drupal module and create tables

create install script for drupal module and create tables
create install script for drupal module and create tables

In this article I will tell how you can create the sample drupal module with custom two table. When you activate the drupal module then tables which are defined in the module will be get installed. When you unactive the drupal module tables will get deleted from database.

For creating the drupal module three files are necessary and that as follow:

1. yourmodule.info (you can use your module name

2. yourmodule.install

3. yourmodule.module

First .info file is important and in that file we will put module related information. mymodule.info file has following content.


; $Id$
name = My module
description = This module is to test the install feature
core = 6.x

For creating custom tables you can use following code in mymodule.install file.


<?php
function mymodule_schema() {
 $schema['mymodule_test'] = array(
 'description' =--> t('The base table for saved articles.'),
 'fields' => array(
 'id' => array(
 'description' => t('The primary identifier'),
 'type' => 'int',
 'unsigned' => TRUE,
 'not null' => TRUE),
 'uid' => array(
 'description' => t('The user identifier.'),
 'type' => 'int',
 'unsigned' => TRUE,
 'not null' => TRUE,
 'default' => 0),
 'name' => array(
 'description' => t('The name.'),
 'type' => 'varchar',
 'length' => '100',
 'not null' => TRUE,
 'not null' => TRUE),
 ),
 'primary key' => array('id'),
 );

 $schema['mymodule_test1'] = array(
 'description' => t('The base table for saved articles.'),
 'fields' => array(
 'id' => array(
 'description' => t('The primary identifier'),
 'type' => 'int',
 'unsigned' => TRUE,
 'not null' => TRUE),
 'uid1' => array(
 'description' => t('The user identifier.'),
 'type' => 'int',
 'unsigned' => TRUE,
 'not null' => TRUE,
 'default' => 0),
 'name' => array(
 'description' => t('The name.'),
 'type' => 'varchar',
 'length' => '100',
 'not null' => TRUE,
 'not null' => TRUE),
 ),
 'primary key' => array('id'),
 );

 return $schema;
}

function mymodule_install() {
 // Create my tables.
 drupal_install_schema('mymodule');
}

function mymodule_uninstall() {
 // Drop my tables.
 drupal_uninstall_schema('mymodule');
}
?>

.Module file is most important. In this file you can put the code which for you written the module. Now in this file Now I am giving you the sample menu code. mymodule.module file has following content.


<?php
function mymodule_menu() {

 $items['mymodule'] = array(
 'title' =--> 'mymodule View',
 'page callback' => 'mymodule_view',
 'access arguments' => array('access content'),
 );

 return $items;
}

function mymodule_view()
{
 return 'test';
}

?>

If you have some more doubts then please content me and comment on this article.

If you want more drupal tutorials than visit here

How to install Mysql workbench on Fedora

You can use following commands for installing the Mysql workbench on Linux system. You can use following commands for installing the Mysql workbench on Linux system. you will get answer of how install mysql workbench, is very nice tool for creating the ER diagram on mysql database. I personally like that tool so much.

how install mysql workbench

[root@sonyk-pc sony]# rpm -Uvh remi-release-11.rpm
warning: remi-release-11.rpm: Header V3 DSA signature: NOKEY, key ID 00f97f56
Preparing… ########################################### [100%]
1:remi-release ########################################### [100%]

[root@sonyk-pc sony]# yum –enablerepo=remi install mysql-workbench
Loaded plugins: refresh-packagekit
remi | 3.0 kB 00:00
remi/primary_db | 198 kB 00:01
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package mysql-workbench.i586 0:5.2.26-1.fc11.remi set to be updated
–> Processing Dependency: mysql-connector-c++ >= 1.1.0-0.1.bzr888 for package: mysql-workbench-5.2.26-1.fc11.remi.i586
–> Processing Dependency: python-paramiko for package: mysql-workbench-5.2.26-1.fc11.remi.i586
–> Running transaction check
—> Package mysql-connector-c++.i586 0:1.1.0-0.1.bzr888.fc11.remi set to be updated
—> Package python-paramiko.noarch 0:1.7.5-1.fc11 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================================================
Installing:
mysql-workbench i586 5.2.26-1.fc11.remi remi 14 M
Installing for dependencies:
mysql-connector-c++ i586 1.1.0-0.1.bzr888.fc11.remi remi 252 k
python-paramiko noarch 1.7.5-1.fc11 updates 982 k

Transaction Summary
==================================================================================================================================================================================================================================
Install 3 Package(s)
Upgrade 0 Package(s)

Total download size: 15 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): mysql-connector-c++-1.1.0-0.1.bzr888.fc11.remi.i586.rpm | 252 kB 00:03
(2/3): mysql-workbench-5.2.26-1.fc11.remi.i586.rpm | 14 MB 02:17
http://fedoramirror.hnsdc.com/updates/11/i386/python-paramiko-1.7.5-1.fc11.noarch.rpm: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
(3/3): python-paramiko-1.7.5-1.fc11.noarch.rpm | 982 kB 00:09
———————————————————————————————————————————————————————————————————————————-
Total 98 kB/s | 15 MB 02:34
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 00f97f56
remi/gpgkey | 1.3 kB 00:00
Importing GPG key 0x00F97F56 “Remi Collet ” from /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : python-paramiko-1.7.5-1.fc11.noarch 1/3
Installing : mysql-connector-c++-1.1.0-0.1.bzr888.fc11.remi.i586 2/3
Installing : mysql-workbench-5.2.26-1.fc11.remi.i586 3/3

Installed:
mysql-workbench.i586 0:5.2.26-1.fc11.remi

Dependency Installed:
mysql-connector-c++.i586 0:1.1.0-0.1.bzr888.fc11.remi python-paramiko.noarch 0:1.7.5-1.fc11

Complete!
[root@sonyk-pc sony]#

After installation you will find the mysql workbench under application-> programming  menu

After that you will you will see the following screen.

how install mysql workbench
how install mysql workbench

clicking on new connection you can create the new connections and after that If you want to create the ER diagram then go to database Option and reverse engineering.

How you find this article for “how install mysql workbench”. please write to me.

Another mysql related article which will be helpful to you.

Install Mysql cluster on Fedora box
How to take mysql backup from file system

How to put digg button in wordpress without plugin

Recently digg launched the version 4 and many people want to put digg button on there wordpress sites and blogs. There are many wordpress plugins available for putting digg button on wordpress.

How to put digg button in wordpress without plugin

But I cannot recommend to use the wordpress plugin for putting the digg button.

How to put digg button in wordpress without plugin
How to put digg button in wordpress without plugin

You can use the following code in your wordpress theme for putting the digg button.

In loop you can use the following code.For Index.php file or archive.php or category.php you can use following code.


digg_url = '<?php the_permalink() ?>';
digg_title = '<?php the_title() ?>';
</script>

<span><span><span>
<span>0</span><a>digg</a></span></span></span>

In single page and pages or without loop you can use following code in single.php and page.php file. Use the following code.


<script type="text/javascript">// <![CDATA[
(function() { var s = document.createElement('SCRIPT'), <span class="hiddenSpellError" pre="" data-mce-bogus="1">s1</span> = document.getElementsByTagName('SCRIPT')[0]; s.type = 'text/javascript'; s.async = true; s.src = 'http://widgets.digg.com/buttons.js'; s1.parentNode.insertBefore(s, s1); })();
// ]]></script>

You can use various size of digg button in your wordpress site.

For above buttons you need to specify the button size in anchor class. as like following.

<script type="text/javascript">
(function() {
var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://widgets.digg.com/buttons.js';
s1.parentNode.insertBefore(s, s1);
})();
</script>
<!-- Medium Button -->
<a class="DiggThisButton DiggMedium"></a>
<!-- Large Button -->
<a class="DiggThisButton DiggLarge"></a>
<!-- Compact Button -->
<a class="DiggThisButton DiggCompact"></a>
<!-- Icon Button -->
<a class="DiggThisButton DiggIcon"></a>

remove blog word from wordpress permalink url

Many times we need to remove the category or blog slug from wordpress URL.  We can very easily remove the blog word from wordpress blog URL. In this tutorial, We are going to show remove blog word from wordpress permalink url. this is useful when you upgraded your wordpress multisite installation.

remove blog word from wordpress permalink url

I personally used wordpress mu for long time. When wordpress 3.0 launched with multisite functionality we started using wordpress 3.0. Removing blog and category slug is very important for many clients.

I am assuming you are using wordpress 3.0 multisite installation. If that is so then you need to do following action.

First login to wordpress admin and go to Super Admin > Sites > Edit

and Scroll down to “Permalink Structure” and remove the “/blog” part. That should work.

Image is shown as like.

remove blog word from wordpress permalink url
remove blog word from wordpress permalink url

than update the option and your issue will be solved. If you are still facing issue then you need to use following code in your functions.php file. Following code is useful for those who updated wordpress mu from wordpress 3.0, other wise they can use above action.


add_filter("pre_update_option_category_base","remove_blog_slug");
add_filter("pre_update_option_tag_base","remove_blog_slug");
add_filter("pre_update_option_permalink_structure","remove_blog_slug");

/* just check if the current structure begins with /blog/ remove that and return the stripped structure */
function remove_blog_slug($tag_cat_permalink){

if(!preg_match("/^\/blog\//",$tag_cat_permalink))
return $tag_cat_permalink;

$new_permalink=preg_replace ("/^\/blog\//","/",$tag_cat_permalink );
return $new_permalink;

}

If you want advanced permalinks then I can suggest following wordpress plugin for changing the permalink

Advanced Permalinks

advanced permalink options that allow you to:

  • Have multiple permalink structures. Permalinks can be assigned to posts or ranges of posts
  • 301 redirect old permalink structures (many structures are allowed)
  • Category-specific permalinks. Posts in certain categories can be assigned a permalink structure
  • No need to have a base to the category permalink!
  • Change author permalinks
  • Enable periods in permalinks – perfect for migrating old websites

If you need more information or help then you can contact me through contact form.

Digg Version 4 is launched to compete with Twitter

This week Digg.com launched the version 4. After long time and digg.com completed the development of version 4 and they launched version successfully.  The new design and features are really nice.

Digg Version 4 is launched to compete with Twitter

The best part what we found is we can register with facebook and twitter accounts.

Digg Version 4 is launched to compete with Twitter
Digg Version 4 is launched to compete with Twitter

You can find the facebook friends and twitter people and google friends for follow them.

What digg.com is saying about version 4?

I’m excited to announce that today we opened up the newest version of our Digg platform. We’ve been working hard on this next evolution of Digg (what we’ve been calling “v4”) and everyone here is really looking forward to hearing your thoughts on the changes we’ve made.

This redesign is a major revision of our platform – front end to back end – this is just phase one of what will be an on-going, iterative process, involving lots of input from all of you. We’ll be pushing out features on a regular basis and tweaking often.

Our goal has always been for Digg to be a place where people can discover and share content and conversations from anywhere on the web. With Digg v4, we are introducing a few things that will make discovering and discussing news a lot better.

New features of Digg.

  • Speed – the new Digg is faster in every way: submitting articles, loading pages, and Digging content.
  • Personalization – we put a lot of thought into how people consume news and wanted to make it easy to view content from the friends, publishers, and influencers you care about. Once you start following your friends, and sources you trust, we’ll build a custom news homepage for you called “My News”. Customizing Digg will enable you to see your friend’s recent Digg or Comment, as well as the latest article submitted by a publisher.
  • Friends & sharing – the new Digg is all about making it easy to see the stories your friends are Digging and commenting on, and to share interesting stories with them. You’ll notice activity from the profiles you’re following highlighted in stories, on comment pages, and even on their profile page as you navigate the site. Attach your blog or RSS feed to your profile and send your followers content as you create it.

how to show featured posts in wordpress homepage

For show featured posts in wordpress on home page. You can select article to show on home page. We have code snippet for show featured posts in wordpress. Showing featured post is good for seo also. Important and selected article you can show on home always. Featured post is great functionality introduced by wordpress.

show featured posts in wordpress

Some times we want to need to show featured posts in wordpress blogs on home page. You can select most popular or nice articles to show on home page. In this tutorial I will will show how you can show the featured wordpress posts on home page.

There is very simple way to show featured post on home page. First you need to create featured wordpress category and whatever post you want to show as featured post that posts select under featured post.

Then use following code:

<?php
  query_posts('category_name=featured&posts_per_page=5');
  if (have_posts()) : while (have_posts()) : the_post();
?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php endwhile; endif; ?>

Above code you need use in index.php and single.php file. Or you can following code for showing featured wordpress post.

 <?php while ( have_posts() ) : the_post() ?>

      <?php  if(get_post_meta($post->ID, 'type', true) == "featured") {; ?>
  <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark">
<img src="<?php echo get_post_meta($post->ID, 'intro_thump', true); ?>" alt="Icon for Post #<?php the_ID(); ?>" />
</a></h2>
<?php  }; ?>
<div class="entry-content">

     </div><!– .entry-content –>
<?php endwhile; ?>
show featured posts in wordpress
show featured posts in wordpress