BAC Software Consulting Blog

How to Delete and Limit Post Revisions in WordPress

WordPress 2.6 and above has a new feature which is the posts and page revision. WordPress automatically creates revisions of your posts or pages. Whenever you save a post or a page, the old version is retained so you can revert back at any time. Older revisions are never deleted so you always have a full history of all changes. However, this feature causes your WP database to rapidly increase in size. Depending how active your blog is, revisions can seriously bloat your database with multiple copies of the same post. Each additional revision will slowly increase the size of your MySQL database.

Sometime it is necessary to do some cleanup. Every revision requires a separate record in wp_posts table and probably entries in the wp_term_taxonomy, wp_postmeta and wp_term_relationships tables. Removing older revisions will free up disk space.

Too many revisions stored in the database might cause longer query time. This means that your blog will load slower and your visitors may wait longer before the content loads. This also leads to high CPU or memory load on your Web hosting server. To my shock, I realized that in this blog I have anywhere from 9 to 47 unnecessary revisions per post/page. Wow!

Does reducing the database size, also speeds up your Website load time?

As you can see from the above image, removing old revisions is one of the best things you can do to your WordPress blog to keep it running efficiently. For a personal blog, many versions of the same post is a waste of resources. Excessive revisions will increase the burden on the database, slows down your WP admin area, your phpMyAdmin and may slow down the download time of your WP Website.

WP Revision Options

The WP_POST_REVISIONS constant has 3 options.

  1. true (default), -1: store every revision
  2. false, 0: do not store any revisions (except one for auto save)
  3. (int) > 0: store that many revisions (+1 auto save). Old revisions are automatically deleted.

Deleting Existing Revisions Using SQL command

Before we start, I am going to say this once: BACK UP YOUR DATABASE. You are about to run SQL statements to your WP database, and if you make a mistake you can revert back to your backup version.

To permanently delete all existing revisions for all pages and posts, login to your phpMyAdmin, select your WordPress database, click on the “SQL” button and paste the following code in the SQL command window. For a detailed explanation about SQL command1, the tutorial is in the References section at the end of this post.

SQL command1:

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy d ON ( b.term_taxonomy_id = d.term_taxonomy_id)
WHERE a.post_type = 'revision'
AND d.taxonomy != 'link_category';

My WP Database After Executing SQL command1

After executing SQL command1I noticed that NOT all stored revisions are deleted in the my WP database. Checking the post_type field in the wp_posts table, I noticed that there are still many “history” data that have not been removed. It seems that the above code still leaves some traces behind. This brings me to the execution of the next SQL command2.

To better explain, the wp_posts table has a field named post_type. This field can have many values, such as post, page or revision. When we want to get rid of all revisions, we run a SQL command to delete any entry in the wp_posts table in which the post_type field is equal to revision.

Again, in your phpMyAdmin area, click on the “SQL” button, and paste the following code in the SQL command window, and hit Go.

SQL command2:

DELETE FROM wp_posts WHERE post_type = 'revision';

My WP Database After Executing SQL command2

Now after executing SQL command2, all previously saved revisions stored in the WP database are totally removed. There are no orphaned data left in the database.

The following table shows my WP database before and after executing SQL command1 and then SQL command2.

 table: wp_posts
(Records)
table: wp_postmeta
(Records)
table: wp_term_relationships
(Records)
Database size
(KB)
Database reduced by:
(Compared to Baseline)
Baseline
(Before Executing the SQL commands)
7892154947,558n/a
After Executing SQL command14162151214,99333.93%
After Executing SQL command24421512150993.26%

Wow! After executing SQL command1 and then SQL command2, the size of the database has been reduced by 93.26%, and the wp_posts table has now 44 records down from 789 records originally. That would tell you how much the WP revision feature can accumulate unnecessary records in the database. Now the question that comes to mind is how to prevent or at least limit the number of revisions in WordPress?

Disable or Limit Revision feature in WordPress

To Disable WordPress Post Revisions:

You can turn off post/page revision feature by editing your wp-config.php file located in your WordPress root directory. Simply add the following code at the top of the wp-config.php file:

//Turn OFF WP revisions feature. 
define('WP_POST_REVISIONS', false);

You could put the code above anywhere at the beginning of the config file as long as it is inside the opening PHP tag (<?php)

To Limit WordPress Post Revisions:

Alternatively, you can use a positive integer to limit the number of revisions.

//Limit WP revisions. Value can be any positive integer number.
//Create a maximum of 2 revisions, plus one for auto-save.
define('WP_POST_REVISIONS', 2);

What About Website Loading Speed?

After the size of the database has been significantly reduced (93% in my case), I noticed that:

  1. WordPress administration area is faster to load and to respond to user requests.
  2. phpMyAdmin area, where the WP database reside, is faster to respond to user requests.

But the biggest question I have: Did deleting WordPress post and page revisions have any impact on this Blog loading speed?

Does Deleting Post and Page Revisions Speed up Your WordPress Website?

I would say that the improvement of this blog´s download time is statistically insignificant. What remains to be seen is that if you have a much larger database with hundreds of posts, would that make a significant difference?

DoFollow Versus NoFollow What to Choose for Your Website?

DoFollow and NoFollow are important factors for SEO that influence the ranking of a particular Website in search engines. DoFollow is a term that does not exist. It is a term given to Websites that are not using the rel=“nofollow” attribute in links. nofollow is a value that can be assigned to the rel attribute of the HTML link to instruct some search engines not to pass on any influence to an outbound link. NoFollow and DoFollow control how a Website passes its PageRank or link juice to other links.

Although search engines don´t pass along the link juice (or let PageRank flow) they still follow and index these links. The nofollow value is not meant for preventing content from being indexed by search engines.

What Exactly is NoFollow?

NoFollow (rel=“nofollow”) means that PageRank or Link juice will NOT be passed to a link. It tells major Search Engines, especially Googlebot, that this link can be followed, the linked page is crawled and indexed, but the PageRank score will not be taken into account.

The attribute that defines a link as NoFollow is rel=“nofollow”.

A typical NoFollow link is like this:

<a rel="nofollow" href="https://bacsoftwareconsulting.com/" title="">BAC</a>

What Exactly is DoFollow?

DoFollow is the exact opposite of NoFollow. A DoFollow link will let your PageRank flow to all external and internal links. When you remove the rel=“nofollow” attribute from a link, then the link becomes DoFollow. The absence of the nofollow value makes the link a DoFollow. Search Engines robots, especially Googlebot, will crawl the link, index it and the PageRank score will be taken into account.

A typical DoFollow link is like this:

<a href="https://bacsoftwareconsulting.com/" title="">BAC</a>

How Do I Know if a Website is Using NoFollow?

There are 2 ways to check:

  1. View the Source code: Highlight the link that you want to check and view the source code of the Webpage. There are several ways to To view the page source depending on the browser you use. You could either select “source” from your browser´s menu or you could right click on the page to view the source from the context menu.
  2. Use an Add-On: Mozilla Firefox and Google Chrome browsers have add-ons that highlight a NoFollow link on a Webpage without actually looking at the source code.

Advantages of rel=“nofollow” Attribute

  1. Minimize Comment Spam: Especially the comment spam that is manually filled by real users once they know that your Website is DoFollow. Automatic spam will not be affected. Robots that submit spam will not check your link status.
  2. Not Passing on Your PageRank:You might not want to pass your PageRank to Websites that are completely unrelated to your field, as this, with time, may cause your PageRank score to go down.
  3. The overall PageRank of your Website is preserved.

Disadvantages of rel=“nofollow” Attribute

  1. You will not attract more visitors to comment on your Website, thus getting less traffic.
  2. Without improving popularity, you may not get inbound links to your Website. Thus your PageRank will not improve.
  3. Less traffic, means less clicks to any advertisements you have on your Website, and thus less earnings.

Where Should I use rel=“nofollow” Attribute

Use the rel=“nofollow” attribute whenever you don´t want to pass your link juice. Regardless what you read otherwise, never add nofollow to any internal pages of your Website. Here are some scenarios when to use NoFollow:

  1. Use NoFollow for single pages that has more than 100 links. For example, a resource page having several hundred links.
  2. Use NoFollow for Trust Badges: like the Better Business Bureau and VeriSign, you can add rel=“nofollow” to those links.
  3. Use NoFollow for your RSS feed. This ensures that your RSS feed isn´t indexed before your Website.
  4. Use NoFollow when linking to any “questionable” and untrusted Websites.
  5. Use NoFollow for mega Websites and Social Networks such as: Facebook, Gmail, Adsense, etc.
  6. Use NoFollow if you link to Web browsers such as Mozilla and Chrome.
  7. Use NoFollow for paid advertising. If you sell advertisement space on your Website, those ads should always have a rel=“nofollow” attribute inserted in the Link.
  8. Use NoFollow for affiliate links.

Is NoFollow a Bad Thing?

No not necessarily, consider the following: The NoFollow links might have no effect on PageRank but they still refer real people. As long as “real visitors” can follow the links, that´s great. Eventhough you do not get link juice from the NoFollow links, you still get real visitors.

NoFollow isn´t bad. There´s nothing wrong with getting NoFollow links. While they don´t pass link juice, they do help associate your Website with anchor text.

Advantages of DoFollow

The advantages of adding DoFollow links on your Website are:

  1. You will attract more visitors especially for comments, thus getting more traffic, exposure and popularity.
  2. With an increase in popularity, you may get more inbound links to your Website, which helps your PageRank to increase.
  3. The increase in traffic may also increase your revenue from affiliate programs and other advertisements.

Disadvantages of DoFollow

  1. The PageRank of your Webpage will be passed to external links. The overall PageRank can be reduced.
  2. However, you can offset the decrease of your PageRank by attracting more inbound links.
  3. You get an increase of spam Comments, which require extra time and efforts from your side.

Which Links Should be Set as DoFollow?

To reemphasize, the non-existence of the rel=“nofollow” attribute, means that the link is DoFollow. Links that should be kept DoFollow are:

  1. All Internal Links. Internal links will help spiders crawl your pages more deeply and they will get indexed often.
  2. For a blog, links pointing to posts should be kept DoFollow.
  3. Niche links can be DoFollow. Always give a link to a Website that shares the same content as yours.

Why Blog Owners Abandon DoFollow?

The answer is simple Comment spam. Spam does not have to be automated. A person can leave just as many worthless comments as software just to get link juice. For every person who takes the time to make a genuine comment, there are several who do the following:

  1. Leave a trivial comment.
  2. Leave a short summary of the Post.
  3. Leave a flat out spam comment unrelated to the topic.
  4. Leave spam comments on several posts in one session.

Conclusion

  1. Ultimately, as long you keep providing great content and services that people want, your Website will grow.
  2. Whatever your decision is, just remember that one “authoritative” link can be more effective than several low level links.
  3. You can build relationships through commenting. Leaving thoughtful comments is a good way to start a relationship with an influential blogger in your field.
  4. Remember that DoFollow blogs are giving you link juice in exchange for your quality comments. So, be considerate. If you post junk comments, blog owners will get tired of moderating and taken advantage of, and will eventually turn NoFollow back on.

So What would I choose? The best approach is to use a mixture of DoFollow AND NoFollow links.

A Closer Look At HTML Versions

HTML has evolved into one of the most used and highly recommended markup languages. Web developers, both amateurs as well as professionals have tremendously benefited from the emergence of HTML. The frequent release of different HTML versions reflects the growing popularity of the language. Through this post, I will be familiarizing you with different versions of HTML which have created a wave in the world of web development. So, let’s examine each of these HTML versions closely.

1. First Version – HTML

Well, the very first version of HTML didn’t come with a number. IT was just called “HTML” and was solely used for creating simple web pages. Marking its use way back in 1989-1995, this first version of HTML was later standardized by IETF and numbered as “HTML 2.0”(explained under point no.2 below).

2. Second Version – HTML 2.0

Considered as the very first definitive HTML version, the initial draft of HTML 2.0 was being re-written and revamped by Karen Muldrow in July 1994. After this, it was being presented at an IETF meeting in Toronto. The sole purpose of this draft was to capture the most common HTML practice in web browsers. Some of the features absent in HTML 2.0 include: support for tables or ALIGN attributes, Netscape/Microsoft extensions etc.

3. Third version – HTML 3

Released back in late 1995, HTML 3 was a result of the tireless efforts put in by Dave Raggett who was inclined on upgrading the features and utility of HTML. Although this version was never implemented, a majority of its features were being integrated in HTML’s next official version which was known as HTML 3.2.

Version 3.2 of HTML came equipped with an integrated support for images, Tables, heading and a variety of element ALIGN attributes. Serving as the current “universal” dialect, HTML 3.2 could be understood by all the major browsers. However, some features which went missing in HTML 3.2 comprised of EMBED, FRAMES and APPLET. This HTML version was being presented by World Wide Web Consortium (W3C) in the year 1997. Published in January 1997, HTML 3.2 included attribute alignment, tables, headings, images and a lot more.

4. Fourth Version – HTML 4.0

Considered as the next major release of HTML, version 4.0 was introduced in December 1997. As an extension to its existing feature set comprising of multimedia, text and hyperlink, this version of HTML included advanced multimedia options, style sheets, scripting languages, improved printing facilities and documents, which are accessible to users with specific disabilities. This version of HTML has also taken stride towards the internationalization of documents, with the sole aim of ensuring maximum evolution of the World Wide Web.

HTML 4.01

Yet considered as another official release of HTML, the version 4.01 includes support for a majority of extensions in addition to features such as extra TABLE, JavaScript enhancements, support for internationalized documents, FORMS and Cascading Style Sheets. Released in December 1999, HTML 4.01 was being presumed to be replaced by a brand new language called XHTML-Extensible HyperText Markup Language. Recognized by all the modern browsers, HTML 4.01 serves as the perfect option for building an intranet where the browsers support just the 3.2 or 4.0 tags. W3C has always been recommending that authors and user agents prefer producing HTML 4.01 documents instead of HTML 4.0 documents. In addition to this, W3C also recommends that the authors must generate HTML 4 documents instead of HTML 3.2 documents. Last, but definitely not the least, W3C recommends that all the tools which are interpreting HTML 4 must continue supporting both, HTML 2.0 and HTML 3.2.

5. Fifth Version – HTML 5

Assumed to be the last HTML version, HTML 5 was released in January 2008 and was published as a W3C Recommendation on October 2014. Equipped with its own HTML serialization, HTML 5 has a syntax which reminds us of the very popular SGML syntax. Plus, this HTML Version also comprises of an XML that’s based on XHTML5 serialization. Although HTML5 isn’t fully supported by some older browsers, there are polyfills which can easily use JavaScript for making specific features work in these browsers. For instance, html5shiv uses JavaScript for allowing older IE (Internet Explorer) versions to recognize and style specific HTML elements.

Conclusion

So now that you know all the different versions of HTML, it is up to you to make a wise choice in accordance to your requirements. Hope the information provided above would enlighten you to take a good decision.

5 ways to Enhance User Experience

Today where internet is flooded with many options for web users, online businesses has changed their motive to keep their visitors interested rather than increasing sales. The better the user experience on the website, the better the chances of growing in the market. In order to make your online business a big hit, it is important to make your website user-friendly.

What is considered for making a website user-friendly? Is it the amount of information we offer on our website? Or how beautiful it looks? Though these two are considered important, there are many other factors that will definitely persuade your visitors in a positive way.

Here are 5 ways to enhance User Experience for your website:

But First, What is User Experience?

According to Wikipedia: User experience (UX) involves a person’s emotions about using a particular product, system or service. User experience includes the practical, experiential, affective, meaningful and valuable aspects of human-computer interaction and product ownership. Additionally, it includes a person’s perceptions of system aspects such as utility, ease of use and efficiency.

1. Implement Responsive Design

Responsive web design has been creating a buzz since its introduction. You probably have seen many websites making use of this new technology to drive more traffic to their website. Responsive design is no longer an option; it has become the need of the hour. Whether you already have an online presence or planning to build one, responsive layout is not something you can overlook in today’s world.
Responsive layout is a website design approach intended to craft websites to offer the best possible viewing experience to the user — easy navigation and reading with a minimum of scrolling, panning and resizing — over a wide range of platforms (from personal computers to smartphones).

2. Add Interactive Elements

Nearly every business is user-oriented. As they say “customer is king”, getting the attention of your visitors in the first few seconds is necessary to keep them interested in your site. Presenting interactive elements in front of your visitors gives them an opportunity to communicate with the site directly. Don’t make them wait for something they badly want, instead try to offer them options that address their needs. You can add infographics, a combination of content, images, videos, colors and movements, to make your content more interesting.

3. Get Feedback from your Visitors

Feedback is a great way to improve your website and services. You can either create one feedback page or simply make use of third party tools to get the valuable feedback on your website structure, design, page loading speed and appearance from your visitors. You can even install certain WordPress plugins like YOP Poll, Opinion stage, and Feedweb to know your visitors reviews.

4. Keep Social Media Registration Options

Nobody likes to register to a website. Adding social media registration option such as twitter, Facebook, and Google+ makes it easier for visitors to register and read your valuable content. You can even add Disqus and Facebook comments option to improve user interaction on your website.

5. Don’t use Newsletter Signup Pop-up

Let’s face it; we hate it when pop up comes up now and then while reading something on the site. These newsletter pop ups literally suck! I get it, you just want to produce some sales leads but it only increases the bounce rate of your website. Believe me, don’t ever use it. It is just not worth the time and effort!

Bonus! Other Techniques to Enhance User Experience

There are many more techniques to enhance User Experience (User Experience for the Web (WebUX) is a field on its own), such as:

  • Use a Consistent Design.
  • Optimize Graphical Elements.
  • Easy and Intuitive Navigational Structure.
  • Provide a Search Mechanism.
  • Short (to the Point) Registration Forms.
  • Place Important Information above the fold.
  • Use Breadcrumb Navigation.

CakePHP- What Makes it the #1 Choice for Large Scale Web App Development

The rapidly growing success and popularity of PHP development has given birth to numerous frameworks which have been effectively utilized for developing web services and solutions with a difference. CakePHP is one such PHP framework, which is open source in nature and comes loaded with a set of libraries for the web programming professionals. Today, in this post, I will be looking at some of the most remarkable features of CakePHP which have made it the first preference of developers who are looking ahead to develop large scale web applications using PHP. So, let me walk you through the must-know features of CakePHP.

1. Complete Adherence to the MVC Pattern

As one of the most critical models followed by CakePHP, MVC helps in saving data and connecting multiple queries into a single database. MVC pattern also allows you to update, delete, insert and read the model class in addition to viewing the growth of project. Since large scale websites and web applications need to have a good separation of logic from the presentation, it is the compatibility with the MVC model that makes CakePHP the right fit for developers.

2. Does NOT Require any Configuration

Since CakePHP does not include any complicated XML files, it is quite easy to get started with web development. With no configuration required for CakePHP, you just need to set up your database and head on with development of your web application or website. This saves a lot of your precious time that is otherwise invested in configuring the software using multiple steps.

3. Code Reusability is a Major Plus

As a web programmer working on the CakePHP framework will offer you the freedom of using pre-written code snippets in different web development projects. That means, instead of focusing on writing codes, you can now find time to concentrate on the creative or logical aspect of your web project. Code snippets can be easily fetched from different sources and conveniently integrated with ongoing website/app development projects.

4. A Wide Range of Built-in Features

In CakePHP, a majority of features which are required for building an outstanding website/app are already built-in. Whether it is the database access, authentication, validation or translations; everything is being impressively packed in this robust MVC compatible framework. With everything available by default, you will find more time to look into the specific requirements of your clients with a guaranteed fastest turnaround time.

5. Fully Compatible with the ORM (Object Relational Mapping) Technique

CakePHP development is completely compatible with the ORM technique. That means, all the data is being stored in the form of tables and later showcased as classes. Hence, relationship amongst different tables is being defined using these classes. Additionally, both validation and callback definitions can be easily predefined with the CakePHP framework.

6. Equipped with the CRUD (Create, Read, Update, Delete) Functionality

For easy data management, CakePHP framework has been loaded with the CRUD (Create, Read, Update, Delete) functionality. In other words, you will be able to create, read, update and delete multiple entities within the web development system. It is interesting to know that a majority of data management issues can be easily resolved by mere implementation of CRUD. With this functionality already existing in the CakePHP framework, you can go ahead with building cost-effective and effectual websites and web applications.

7. Quick Web Development is Guaranteed with CakePHP Framework

The numerous built-in features of CakePHP allow developers to build prototypes for their varied clients in a less time-consuming way. These features also create room for rapid web development, allowing you to build applications within the assigned timeframe, thereby avoiding any delays.

8. Completely Safe and Secure

With specific tools available for input validation, form tampering protection and prevention of XSS, CSRF protection and Form tampering, you can find it convenient to build safe and secured web applications for your esteemed clients.

9. Free and Flexible Licensing

Just like a majority of other PHP frameworks, even CakePHP is being widely used due to its free and flexible licensing. As an easy to install framework, CakePHP has free licensing, making it one of the best options for development of complex commercial applications.

10. Supported by an Active Community of Developers

Having chosen CakePHP framework, you can rest assured about receiving quick and accurate answers to all your queries regarding the correct usage of this widely used PHP framework. With the active and friendly community of developers ready to listen and answer your questions, using CakePHP framework would become a complete breeze.

Conclusion

So, if you are planning to build a large-scale application that is robust and well-structured, nothing can beat the CakePHP framework. Here’s hoping the aforementioned pointers would have encouraged you to use the framework right away.

How To Turn Your WordPress Blog From NoFollow to DoFollow Without a Plugin

How To Turn Your WordPress Blog From NoFollow to DoFollow Without a Plugin

In this tutorial, I will show you how to easily turn your WordPress blog from the default NoFollow to a DoFollow blog without the need of a plugin. Why not turn your blog into a DoFollow blog and get more visitors, more traffic and eventualy more recognition in the Online community. Probably you already have seen some blogs displaying the DoFollow image and you wonder how it is done and what it really means. Read my next tutorial for a closer look at DoFollow versus NoFollow.

What are NoFollow and DoFollow?

DoFollow is a term that does not really exist. It is a slang term given to Websites that are not using nofollow. nofollow is a value that can be assigned to the rel attribute of the HTML anchor tag to instruct some search engines not to pass on any influence to an outbound link. The nofollow value was intended to stop comment spam in blogs. Commenting is recognized as a good way to get one way backlinks. But it has been abused and thus the creation of the nofollow value back in 2005.

You might already know that NoFollow blogs do not carry any PR value to other Websites through commenting. If your blog is DoFollow then comments made by your users get Link juice, meaning that your blog passes on the PR value to the commenter.

Should You Set Comment Links To DoFollow?

One way to encourage your readers to comment on your blog is by making your blog DoFollow. If your blog is new and you are trying to increase traffic then you need to turn your blog to a DoFollow blog. When people comment on your content they are adding value to your content. Some consider DoFollow as bribing visitors for comments, while others consider it as rewarding visitors that leave a comment. I tend to agree with the latter, but whatever your opinion is, DoFollow encourages interaction with your readers. One negative side though is that it increases comment moderation duties and an increase of spam comments.

What About a Plugin?

Yes, there are several plugins that turn your blog to a DoFollow blog. But I encourage you to read my previous article about unnecessarily adding plugins to your theme. Also, you really don´t need a plugin for such a simple task.

How does NoFollow and DoFollow Look Like?

The only way to know whether a link has been set to NoFollow is to look at the source code of the page. There are several ways to do that depending on the browser you use. To look at the source code, select “source” from your browser´s menu or you could right click on the page to view the source from the context menu. Also, Mozilla Firefox browser has add-ons that highlights a nofollow link on the page without actually looking at the source code.

The attribute that defines a link as NoFollow is rel=“nofollow”. If you remove the rel=“nofollow” attribute, then your link becomes DoFollow. There is no dofollow value. The absence of the nofollow value makes the link a DoFollow.

A typical DoFollow link is like this:

<a href="https://bacsoftwareconsulting.com" title="">BAC</a>

A typical NoFollow link is like this:

<a rel="nofollow" href="https://bacsoftwareconsulting.com" title="">BAC</a>

Features of My “DoFollow” Code

  1. The code is added to your theme´s functions.php file. The core WordPress code is not modified in any way.
  2. The code is split into 2 independent sections (Section1 and Section2). You have the choice to choose either one or both.
  3. The code is tested to work with the latest version of WordPress. However it also works with earlier versions.
  4. The code is tested to work properly with all major browsers.

“DoFollow” Code | functions.php

To change your Comment links from NoFollow To DoFollow, Open the functions.php file located in your theme´s folder, and add (copy and paste) the following code.

Note: To scroll within the code: You can also click on the code window and use your keyboard´s arrow keys.

<?php
/**** Section1: Changes the author's link in the comment section to a 
'dofollow' instead of the default WordPress  of 'nofollow' ****/
function dofollow_comment_author_link() {
    $url    = get_comment_author_url();
    $author = get_comment_author();
 
    if ( empty( $url ) || ('http://' == $url))
        return $author;
    else
        $link = "<a href='$url' rel='external' class='url'>$author</a>";
        return $link;
}
//http://codex.wordpress.org/Function_Reference/add_action
add_action('get_comment_author_link', 'dofollow_comment_author_link');
/* End of Section1 */
 
/**** Section2: Changes all links in the comment text to a 'dofollow' 
instead of the WordPress default of 'nofollow' ****/
function dofollow_comment_text_link($string) {
    //http://www.php.net/manual/en/function.str-ireplace.php
    $string = str_ireplace('rel="nofollow"', '', $string);
    return $string;
}
//http://codex.wordpress.org/Function_Reference/add_filter
add_filter('comment_text', 'dofollow_comment_text_link');
/* End of Section2 */
?>

“DoFollow” Code Notes:

Note: If you don´t see the horizontal bar, and to scroll within the code, you can also click on the code window and use your keyboard´s arrow keys.

1. Section1 of the above code changes the author´s link in the Comment section to a dofollow instead of the WordPress default of nofollow.

Meaning an Author´s link such as:

<a class="url" rel="external nofollow" href="https://bacsoftwareconsulting.com">BAC</a>

will be transformed to:

<a class="url" rel="external" href="https://bacsoftwareconsulting.com">BAC</a>

2. Section2 of the above code changes all links in the Comment text to a dofollow instead of the default WordPress of nofollow.

Meaning Any link in the Comment text box such as:

<a rel="nofollow" href="https://bacsoftwareconsulting.com">BAC</a>

will be transformed to:

<a href="https://bacsoftwareconsulting.com">BAC</a>

3. You have the choice to apply either Section1 of the code or Section2 or Both. For this Blog, I applied both Sections.

General Warning

When you add several PHP code blocks in your theme´s funtions.php file, make sure that you do NOT leave any white space (spaces, newline) before the opening PHP tag or after the closing PHP tag. Like so (the correct way):

<?php 
//Some Code here beetween the opening PHP tag (above) 
//and the closing PHP tag (below)...
?>
<?php 
//Some other Code here ...
?>

In the above code, if you leave any white space or a newline between lines 4 and 5, you will get the following error: Warning: Cannot modify header information – headers already sent by … , in your login screen and after you login to your WordPress dashboard.

Your Turn to Talk

What is your opinion about NoFollow or DoFollow? Does link juice mean anything to you? How easy did you find this tutorial to implement?

If you have something to say, please share your opinion in the DoFollow Comment section and get your reward. Your opinion matters, unless it is a Spam. By the way, this blog is now a DoFollow blog.