Applying a filter in a wordpress website

You can apply a filter in a wordpress website easily

Suppose you want your name to be added to the end of site title you can use a filter

  1. Use add_filter function to register the filter function
  2. Define the filter function which takes the input parameter as value to be filtered
  3. Return the filtered value of the function
 PHP |  copy code | ?
1
<?php
2

3
add_filter('wp_title', 'title_filter',10,2);
4

5
function title_filter($title,$postattr){
6
$title=$title." | Myname";
7
return $title;
8
}
9

Here in the add_filter function parameter 3 signifies the weight of the plugin and 2 defines the number of parameters it takes

You can add a function in the class too.. using the array attribute

 PHP |  copy code | ?
01
<?php
02

03
add_filter('wp_title',array('MyClass','title_filter'),10,2);
04

05
class MyClass{
06
  function title_filter($title,$postattr){
07
    $titile=$title." | ". "Myname";
08
    return $title;
09
    }
10
}

WordPress plugin for displaying code snippet

I was looking for a nice plugin for displaying code snippet in my wordpress blog. I found a great list of such plugins through this http://blog.templatemonster.com/2011/04/15/wordpress-plugins-code-snippets-displaying/

However out of the fifteen plugins listed out there, I liked only 3 of them

  1. Developer Formatter

  2. Google Syntax Highlighter

  3. Syntax Highlighter Evolved

The first one depends on the GeSHI highlight system and does the syntax highlighting at the server side. The later two does it on the client side by Alex Gorbatchev’s Syntax Highlighting code.

All the three supports many number of programming languages

Alex Gorbatchev’s Syntax Highlighting code

I choose the first one because it’s on the server side. Although it may affect server performance with better caching plugins like Quick Cache you can always have a performance gain over others.

Hence my choice is to go for Developer Formatter

Myths about SEO in wordpress.com

We tend to use wordpress.com blogs time to time. It’s a great place to start our own blog and many of us have blogs on it too. One of the things that we disturbed is that why our pages are not displayed when we searched in search engines like google, yahoo and bing. We tend to ask for professional help which most of the times doesn’t do any good.

Here is a great article All About SEO on WordPress.com

I came across which nicely put forward how blogs on wordpress.com are optimized for SEO. We don’t need to be bothered about SEO for blogs on wordpress.com

It exposes the some of the myths as below

  1. I need a plugin for SEO.
  2. I need to regularly submit Sitemaps to Google so it knows I’m blogging regularly.
  3. The more tags and categories I use for a post, the better it is for Google.
  4. Creating several identical sites about sailboats and making frequent use of sailboat-related terminology in my posts will help me get a lot of sailboat-related traffic.
  5. One effective way to improve my blog’s SERP rank is to purchase or exchange links (sometimes known as “backlinks”) with as many bloggers as possible, so that there’s a lot of traffic going to my blog.
  6. SEO requires a strategy and possibly an expert.

Every blogger who is bothered about increasing page ranks should keep in mind these facts

Removing Topic from title in bbpress forums

bbpress is a nice forum plugin that works with WordPress.

In bbpress when you create a topic.. for example “How to create a bbpress topic?” , the title you get when viewing the topic is something like “Topic: How to create bbpress topic?”

.If you want to remove the “Topic” from bbpress forum topics, you can do it using “bbp_title” filter.

This is explained in the following code

 PHP |  copy code | ?
01
<?php
02

03
add_filter('bbp_title', 'custom_topic_title_bbp', 10, 2);
04

05
function custom_topic_title_bbp($title, $postarr) {
06
    $title = str_replace("Topic: ", "", $title);
07
    return $title;
08
}
09

10
?>

If you don’t know how to write code, just download the very tiny plugin below from here and activate it.

Custom-Topic-Title

Once you activate this plugin you’ll see your topic title as “How to create a topic?” instead “Topic: How to create a Topic?”