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

Add google maps in wordpress post

You can add the google maps in wordpress post or pages very easily. You need to just use following code in your functions.php file. Open your functions.php file from your wordpress theme folder and copy paste the following code in that file.

Add google maps in wordpress post

You can Add google maps in wordpress post or pages very easily. Open your functions.php file from your wordpress theme folder and copy our code in file. If you don’t have functions.php file in your wordpress theme folder then create functions.php file and put following code in that file.


//Google Maps adding through Shortcode
function add_googlemap_in_wordpresss_in_wordpress($atts, $content = null) {
 extract(shortcode_atts(array(
 "width" => '620',
 "height" => '430',
 "src" => ''
 ), $atts));
 return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&output=embed" >';
}
add_shortcode("googlemap_in_wordpress", "add_googlemap_in_wordpresss_in_wordpress");

How to use google maps in your wordpress posts and pages.

use the following code in your posts or pages.

[googlemap_in_wordpress width="280" height="280" src="[you_url]"]
Add google maps in wordpress post
Add google maps in wordpress post

You can change the height and width as per your requirement and for url you need to use following url
http://maps.google.com/
go to above url and choose your location and right side top you will find the link option. click on that link url and you will get the link of your location. Just copy paste that url. example as follows

[googlemap_in_wordpress width="280" height="280" src="[http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=New+York,+NY,+United+States&sll=37.0625,-95.677068&sspn=47.215051,79.013672&ie=UTF8&hq=&hnear=New+York&ll=40.555548,-73.730621&spn=0.356317,0.617294&z=11&iwloc=A]"]

Above code put in your post or page. you can see the google maps in your page.

Here is list of some wordpress plugins which will help you to integrate the google map in wordpress.

how to display or embed the google map in wordpress

Twitter follower count using PHP in WordPress

you can easily show twitter follower count in your wordpress site. In this tutorial we used twitter xml api for fetching Twitter follower count using PHP. You can place the twitter count in header section or footer section or sidebar section of wordpress.

Twitter follower count using PHP in WordPress

 

Twitter follower count using PHP in WordPress
Twitter follower count using PHP in WordPress

Using following code you can print the twitter followers count.


<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
$twitter_api = file_get_contents('http://twitter.com/users/show/USERNAME.xml');
$text_output = '<followers_count>'; $end = '</followers_count>';
$page = $twitter_api;
$explode_content = explode($text_output,$page);
$page = $explode_content[1];
$explode_content = explode($end,$page);
$twitter_followers = $explode_content[0];
if($twitter_followers == '') { $twitter_followers = '0'; }
echo '<div><strong>'.$twitter_followers.' </strong> Followers</div>';

?>

You just need to replace the your name instead of USERNAME.

Tweet Button is launched by Twitter

Twitter launched the new share button.  We always used the tweetmeme button for our wordpress blogs and sites.

Tweet Button is launched by Twitter

Tweet Button is launched by Twitter
Tweet Button is launched by Twitter

Button Twitter launched very nice twitter button which has very nice cool look and feel.

If you want to use the new twitter button in your wordpress site than use following code:

<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script></pre>
<div>php the_title(); ?>&via=YOUR_NAME">Tweet</div>
<pre></pre>
<pre>

you will see the button as like this.

If you want to add the big button as follows than use following code:

<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script></pre>
<div>php the_permalink() ?>" data-via="YOUR-NAME" data-text="<!--?php the_title(); ?-->" data-related="<!--?php the_tags( '', ', ', ''); ?-->" data-count="vertical">Tweet</div>
<pre></pre>
<pre>

What Twitter is saying about this button.

The Tweet Button is a small widget which allows users to easily share your website with their followers. This page is for developers and users who wish to build their own Tweet Buttons. If you are looking for a quick way to build a Tweet Button for your website you can visit our Tweet Button Goodies Page.

The user interaction flow for the Tweet Button was designed to be as streamlined as possible and easy to use for both developers, website owners and users.

The steps a user goes through when using the Tweet Button are:

  1. The user clicks the Tweet Button
  2. The user is asked to login to Twitter if they aren’t already. If the user is new to Twitter they can also create an account.
  3. The Share Box appears already completed with the information provided in the properties of the Tweet Button. The user can change the content if they wish.
  4. Posting of the Tweet is confirmed and the user is suggested a maximum of two accounts they may wish to follow as provided in the properties of the Tweet Button.
  5. The Share Box remains open until the user presses close.

You can get the Twitter button from following site

http://twitter.com/goodies/tweetbutton