15% OFF Calorie Free Noodles with coupon code "2LOWCARB"
Powered by MaxBlogPress 

FEN Reader WordPress Plugin

Note: You are viewing a page off my vegan food blog as it was the most convenient for me.

This WordPress plugin enables easy display of a chess position, and information pertaining to its current state, using Forsyth-Edwards Notation (FEN), part of the Portable Game Notation (PGN) standard, by embedding it within the special HTML tags <fen> and </fen>.

The FEN standard is described at Wikipedia thusly:

A FEN record contains 6 fields.
The separator between fields is a space.

The fields are:

1. Piece placement (from white’s perspective). Each rank is described, starting with rank 8 and ending with rank 1; within each rank, the contents of each square are described from file a through file h. White pieces are designated using upper-case letters (“KQRBNP”), Black by lowercase (“kqrbnp”). Blank squares are noted using digits 1 through 8 (the number of blank squares), and “/” separate ranks.

2. Active color. “w” means white moves next, “b” means black.

3. Castling availability. If neither side can castle, this is “-”. Otherwise, this has one or more letters: “K” (White can castle kingside), “Q” (White can castle queenside), “k” (Black can castle kingside), and/or “q” (Black can castle queenside).

4. En passant target square in algebraic notation. If there’s no en passant target square, this is “-”. If a pawn has just made a 2-square move, this is the position “behind” the pawn.

5. Halfmove clock: This is the number of halfmoves since the last pawn advance or capture. This is used to determine if a draw can be claimed under the fifty move rule.

6. Fullmove number: The number of the full move. It starts at 1, and is incremented after Black’s move.


<fen></fen> displays the starting position:

White To Move
White can castle kingside or queenside.
Black can castle kingside or queenside.
There are no en passant captures possible.
The last capture or pawn advance was 0 half-moves ago.
Position at move 1.

w kq – 7 9

White To Move
Black can castle kingside or queenside.
There are no en passant captures possible.
The last capture or pawn advance was 7 half-moves ago.
Position at move 9.

Usage Tips and Tricks

The above is about as much fragmentation as the <fen> tags can handle. The FEN specification requires spaces betwen the fields, but I tried to allow for other whitespace characters or separators.

You may exclude further information from display by leaving off the unwanted fields in the FEN. For example,
<fen>r2qk2r/ppp1bppp/3p4/4n2n/2B1P1b1/2NPBN2/PPP3PP/R2Q1RK1 w</fen> would display only the above diagram and the White To Move text.

If you wish to create a 10×10+ board, which I believe is unsupported by FEN anyway, and have a rank with more than 9 empty squares, you will need to enter them as back-to-back single digits adding up to the desired number. For example, “/82/” within the piece placement field will display a rank with 10 empty squares.


Unzip fen-reader.zip and upload the contained fen-reader.php file to your wp-content/plugins directory.

Create a directory on your website and populate it with the images in this zip file, originally from http://andstuff.org/chess.

From your Plugins menu, activate FEN Reader.

From your Options menu, enter the URL to the just created image directory.


19 Responses to “FEN Reader WordPress Plugin”

  1. Leonardo says:

    Like it a lot. Congratulations.

  2. Erin says:

    Thanks, Leonardo. By the way, I have added an interactive form here, so you can play around with entering positions in FEN and viewing the results.

  3. Leonardo says:

    Erin, I’m having a problem with the plugin. Everytime I change the location of the pieces (the png files), the plugin just don’t change the URL. It keeps my root URL, that is blogueisso.com. Any idea how to fix it?

  4. Erin says:

    Thank you for trying my plugin and reporting this situation. I have patched it up. Please download again, and let me know if the issue has been resolved.

  5. Leonardo says:

    Erin, now it’s perfect. Thanks. I will send the link where I will use it later.

  6. Leonardo says:

    Look, it’s cool.

    Thanks again.

  7. Erin says:

    Sweet! :) I’m so glad someone is getting good use out of it. Thanks for letting me know.

  8. Ramón says:

    Hello, it lowers your plugin, it is very good, but I have had a problem, it installs it and the board leaves to me very wide, and between each piece there is a slight space, since I do to him so that it is like the one of your blog, I do not explain or that becomes the board great, I have not moved him anything to I cosay. Greetings and thanks. p.d. my english is not very good

  9. Erin says:

    I am not sure what advice to offer about this situation. The plugin generates a basic html table. There is no space purposely placed between the pieces.

    Does this only happen with a certain FEN? If so, you could try entering it here to see if it looks any better? Either way, if it is specific to a particular FEN string, please post the culprit.

    Does it affect the display by altering the fonts or resizing your browser or area in which the board is situated?

    Sorry to not be of greater assistance. Maybe a fellow plugin user has some additional thoughts?

  10. Tomas says:

    The problem is the theme. Somewhere in the css of your theme you have something that causes the spaces.

  11. Erin says:

    Thank you, Tomas, for your additional, erudite, suggestion. It seems he has it working now (click on Ramon’s name to be taken to his blog).

  12. billybob says:

    For some reason the wp 2.13 will not allow me to change the path for the graphics for this fen reader – is there a place in the code that will aallow me to hard code the png path?


  13. Erin says:

    In fen-reader.php, in the render_position function,


    $image_url = get_option( ‘fen_reader_images’ );


    $image_url = ‘http://www.mysite.com/image_dir/’;

    where, of course, the URL given is just an example.
    (Note also, the trailing slash is important.)

  14. billybob says:

    Thanks, that worked great.

  15. Peter Gnodde says:

    It would be nice if you gave the table its own class, so it can be defined in the stylesheet by itself

    .fen {
    margin: 0px;
    border: 0px;

    and not a hack like

    .text center td img {
    margin: 0px;
    border: 0px;

    Because it is not impossible that I would like another image in a table which is centered, but with the default style (which has a margin and a border).

  16. Peter Gnodde says:

    btw, the way you generate the table is not correct, the use of a single cell works, but it should at least be defined inside its own row (). It only works because modern browsers are build to parse even the most crappy HTML (yes there is worse ;) ).

    The best way would be to generate a table with 8 rows and each row with 8 cells and let the user define the borders, alignment, spacings and all that using a stylesheet.

  17. Erin says:

    Peter, Peter.

    I reckon you are probably right with your helpful suggestions. Thank you. I knew even less about CSS and HTML standards then.

  18. Hi there,

    thanks for this, looking forward to giving it a go

  19. Hello, Thanks for taking the time to do this and answer everyone’s queries! I have had no problems so far but hours of fun.

Leave a Reply

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

SurfShelf Treadmill Laptop Holder

My Cookbook:

Help get out the word and
make money as an affiliate