Word Press Remove Blank Line From RSS Feed Error Fix

Are you pulling your hair out trying to solve this error? If you are not a geek then most probably you are doing just that!

This error is generated when the feed output generated by WordPress contains a blank space at the beginning of the output page.

The most common cause for this error is a blank space somewhere in between PHP tags in your theme’s functions.php file.

Look for PHP tags that contains a space like this:

Remove the blank space and the feed should work now.

If that did not work out you can try this neat wordpress plugin fix rss feed.

Another alternative is to disable all your plugins one by one and check out the feed output. If your feed starts working after deactivating a particular plugin, then check out the PHP functions in that plugin files. Here again, the main issue could be a gap between PHP tags as decribed above. Remove all such spaces. Since this requires knowledge of wordpress plugins, this method is not recommended for non-programmers.

Also, do not forget to back up your wordpress database and files before tampering with any plugin file.

If everything else fails – then hire an expensive programmer to do the task!

Do you have any other methods to solve this error? Please share in the comments below.

Get Users List by Role in WordPress

To get the list of all users in your wordpress blog use the following code:

[php]

<?php

$users = get_users();

?>

[/php]

This function returns an Array of user objects as follows:

[html]
Array
(
[0] => stdClass Object
(
[ID] => 1
[user_login] => admin
[user_pass] => ***************************.
[user_nicename] => admin
[user_email] => admin@localhost.com
[user_url] =>
[user_registered] => 2011-06-25 18:05:28
[user_activation_key] =>
[user_status] => 0
[display_name] => admin
)

[1] => stdClass Object
(
[ID] => 2
[user_login] => seema
[user_pass] => ***************************
[user_nicename] => seema
[user_email] => seema@localhost.com
[user_url] =>
[user_registered] => 2011-06-25 18:12:53
[user_activation_key] =>
[user_status] => 0
[display_name] => seema
)

)
[/html]
You can use a foreach loop to extract the required user information.

For example – if you want to extract only the user names, you would do the following loop

[php]
<?php

$users = get_users();

foreach( $users as $user )
{
echo $user->user_nicename;

echo ‘<br />';

}
?>
[/php]

The above code is fine as long as you want all users in your blog. But when you need users by roles, you will need to pass certain parameters to the function get_users();

Say, you want all users with the role “agent”. The following modified code will get you all the user from role agent

[php]
<?php

$args[‘role’] = ‘agent';

$users = get_users( $args );
?>
[/php]

What we are doing here is passing an argument role to the get_users() function telling it to return only those users who belong to the role agent.

You can pass more arguments to the get_users() function to filter the returned users as per your requirements.

For a detailed list of arguments check out this article at wordpress codex

Note that this function is available from WordPress version 3.1 onwards.

What Every WordPress Plugin Developer Should Know

This is one excellent tutorial from smashingmagazine.com

In a nutshell following are the main points from this article

1. Turn on debugging feature before you start developing a plugin
2. Provide unique prefixes to your plugin function names
3. Create global paths for your CSS and JS code
4. Keep track of plugin version for upgrades
5. To create/update your plugin database tables use dbDelta() function
6. Know how and when to use actions and filters
7. Create your own settings page for your plugin

Full article at smashingmagazine

Generating a list of Random Numbers in PHP

I created the following code while working on a wordpress plugin. As usual, first i searched in Google for a short cut way to do this! Turned out, lots of people were having trouble generating a list of random numbers in PHP.

[php]
<?php

$low = 1; //lowest number

$high = 500; //highest number

$not = true;

$max = 5; //number of random numbers that you want

$list = array();

while( $not ) {

$p = rand( $low, $high );

if ( !in_array( $p, $list ) ){

$list[] = $p;

}

$count = count( $list );

if ( $count == $max )
{
$not = false;
}

}

foreach( $list as $val ){

echo $val;

echo "<br />";
}

?>
[/php]