Category Archives: wordpress

wp_list_authors exclude one or multiple users based on name or userid

Skip to about 1:50 – the first part i thought i cut out, but i didn’t, so the first part is just rambling.

So currently (at the time of this video) wordpress doesn’t allow you to exclude specific authors based on id, so i found a fairly easy work around to make it happen for me.

These changes take place in the wp-includes folder / which means with every site upgrade these changes will be erased.
OTHER Notes: You may have to replace the “‘” characters when you copy the code or get a parse error.

firstly here is the code we’re talking about

wp_list_authors(‘exclude_author=1&show_fullname=1&optioncount=1&orderby=post_count&order=DESC&hide_empty=1’);

Found in the wp-includes folder / author-template.php

If you want to exclude the admin from the list of authors, but you’re user isn’t named “admin” all you have to do is find the line of code:

if ( $exclude_admin && ‘admin’ == $author->display_name )

Somewhere around line 298

If you’re like me and you wanted to exclude multiple authors from the list, then what i did to accomplish that was:

Just after this code:

$author = get_userdata( $author_id );

and before this code:

if ( $exclude_admin && ‘admin’ == $author->display_name )

I added this if statement:

// begin that jon jackson’s code
if (($author_id == ‘1’) or ($author_id == ‘6’)){

// These two numbers were the id numbers of my two authors that i didn’t want to display

}else{ // continue original code

Around line 373 (for me), just before this line of code:

$return = rtrim($return, ‘, ‘);

i closed the if statement checking for those user ids

} // end that jon jackson’s code

the one in which i explain how to add thumbnails into your wordpress rss feed

this is without a doubt, hacking the heck out of your wordpress installation, so if that is something you’re not comfortable with, please go find something else to do.

firstly, our problem is that by default, the feed that comes with wordpress does not include thumbnails, so when you auto-share your feed on facebook to keep all of your friends up to date with your goings on, there is no thumbnail attached to the article.
2009-11-12-083934

whereas when somebody shares a blogpost from say Flickr or Blogspot, they have a nice thumbnail image to accompany the article.
2009-11-12-084053This brings me to the code.
the files you will need to hack up are as follows:wp-includes/feed-rss2.php

<side note> when i was testing changes to my rss feed, i did two things.

  1. removed line 31 & 32 in “feed-rss2.php”
    <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
     <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>

  2. use a firefox plugin called "Cache Status"
    2009-11-12-084512

    this add-on lets you quickly clear the FF cache so you can refresh your rss feed and see if the edits you just made too effect.

</side note>

below is the original code from “feed-rss2.php” (This begins around like 36)

2009-11-12-084831

and this is the modified code

2009-11-12-085423

and that’s all there is to it!

wait! I hear you say. Where the crap are you getting the info for the “pft_square” variable?

Good question, and i’ll answer you now.
to create thumbnails for my posts i use a great plugin called WP Post Thumbnail.
(as of the time of this post, it is in version: 0.2 Beta 2 ) When i first began using the WP Post Thumbnail Plugin by default it named the thumbnails “pft_square”, “pft_rectangle”, and something else. so since i had already begun using that variable, i kept it.

it can be whatever you like, and i plan to write a loop that checks for several different variables, but i don’t need to right now since i know how it works, so suck on that.

anyway, back to the thumbnail creation for the post.

then i followed these steps:

2009-11-12-085518

2009-11-12-0900282009-11-12-090501then you’re left with this:

2009-11-12-090529

which then gives you a new custom field (once you publish the post) of:

2009-11-12-090638

then your rss feed will include that thumbnail.

2009-11-12-090754

and that as they say, is that.

other helpful Info:

How to Format Images for Feed Readers

How To Insert Custom Image Thumbnail on Facebook Link Sharing

5 tips for optimizing your brands (on facebook)

replace “Protected:” text from a password Protected WordPress post with an image

Our Goal is to turn a page that looks like this:

2009-11-06-141204

To a page that looks like this:
2009-11-06-141730

What file to do you edit?

  • in the wp-includes folder
  • post-template.php” file arount line 111 (See images below for reference)

Original Code Unedited:

2009-11-06-141914

Edited Code :
2009-11-06-141843

Full original code: begins Line 111
if ( !is_admin() ) {
if ( !empty($post->post_password) ) {
$protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
$title = sprintf($protected_title_format, $title);

Final Edited Code: begins Line 111
if ( !is_admin() ) {
if ( !empty($post->post_password) ) {
$protected_image_title = "
<IMG SRC=http://www.yourdomain.com/img/padlock.gif id=no>";
$protected_title_format = apply_filters('protected_title_format', __('%s'));
$titles = sprintf($protected_title_format, $title);
$title = "$protected_image_title $titles";
// $protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
// $title = sprintf($protected_title_format, $title);

The same thing will work with the “Private:” pages, but i wasn’t concerned with those.