Saturday, March 7, 2009

How to Insert a Table Into a WordPress Blog Post


The default WordPress editor does not allow much HTML and it does not allow tables to be inserted. In this post I’ll show you a neat plugin that allows you to insert tables into your WordPress posts and exactly how to use it.


tables in wordpress blog posts


I was actually first asked about this a little while ago by Trevor Mulligan. At the time I had not needed to insert a table into any of my blog posts so I was unable to help him. A few days ago I published a list of over 100 CSS Galleries which are great for getting backlinks and traffic and I wanted to format the information in a table so I needed to figure out how to do it.


The wp-table Plugin


One of the reasons I love WordPress so much is that its functionality is infinitely expanded by the wide range of plugins available for it. One such plugin is wp-table by Alex Rabe. The instructions on that page work but I found it somewhat non-intuitive to use so I thought I’d do my own little write-up.


Setting up the Tables


Now here’s the weird thing - the plugin provides a table editor but that editor is separate from your blog posts. You create tables for your blog as a whole, each table gets its own ID and then to put a table into a blog post you insert a special tag. I would have expected the table editor to be built into the post editor but it isn’t which is why it’s a little confusing.


Once you’ve uploaded and activated the plugin you get a new option under the manage tab. You can see it below:


wordpress tables manager


That screenshot also shows the one and only table I have at the moment which is the CSS Galleries one. There are two ways to create a table. You can manually add one by specifying the name and the number of rows and columns but that is restrictive as the drop-down only allows 20 rows.


Thankfully there is a second option to import a table from a file. You simply browse from a file on your computer and select a delimiter character to use. Here is a picture of that in action:


import wordpress table data


What I did for my post was to write the information out in Microsoft Excel (Open Office has the same functionality) and then export that as a CSV file. CSV is a Comma Separated file which means that each row in the spreadsheet is exported as one line of text with a comma character separating each column.


Inserting a Table Into a Post


Now once you’ve setup your table, inserting into a blog post (or page) is very simple. Make a note of the ID of the table which is 5 in the example above and then you use the following bracket notation to insert it:


wordpress table bracket notation


Simple really.


Embedding Links in the Text


I hit a snag right away - a CSV file is plain text and I wanted to link to each one of the directories or the post wouldn’t have been nearly as useful. In Excel I was able to automatically turn the url’s into links but as soon as I exported them as a CSV they got stripped back to plain text.


However, the plain text can contain HTML so I changed the text of the link to the HTML required to display as a link using the HREF tag. I knocked up a quick program to do this for me so I didn’t have to do it manually for 100 lines of text!


Basically, if you want links in your table you have to ensure that the source text contains the full HTML to use.

0 comments on "How to Insert a Table Into a WordPress Blog Post"

Post a Comment

 

Butter Barbara Copyright 2008 Fashionholic Designed by Ipiet Templates Supported by Tadpole's Notez