I needed to show search results in an ordered list for a project I am working on and was very surprised to discover how involved this is for paginated search results. Showing the results using a regular ordered list starts the list numbering over at 1 on each new page of results, even though the next set of results was being displayed.

After some horribly hacky solution involving grabbing the page number from the URL and hard coding the number of posts per page, I was led in the right direction by NicktheGeek at StudioPress who suggested getting the number of posts per page from the query string and using the paged value to get the numbers dynamically before applying the math to get the list numbers to display correctly.

A bunch of CSS was required to make the list numbers look like they were actually generated by an <ol> tag. Styling will vary depending on your theme, but one thing that may help if things are looking messed up is to display the post/page titles and contents inline.


For non-Genesis themes, leave out the genesis_ lines.