Wordpress Plugin

  • Tags : content management
  • Latest : 0.2.5
  • Last Updated: 25 November 2010
  • Grails version : 1.2.2 > *
  • Authors : Luis Arias
2 votes
Dependency :
compile ":wordpress:0.2.5"

Documentation Source

Summary

Description

The Wordpress plugin provides tags for pulling content from wordpress for display in grails.

ehcache is used to cache wordpress content for a 5 minute period.

Configuration

You can configure the Wordpress Plugin by setting the following properties in your application's Config.groovy file:

PropertyDescription
wordpress.urlUrl to the wordpress XML-RPC api handler
wordpress.blogIdShould probably always be 0, not currently used by the Wordpress API
wordpress.usernameUrl to a user on your wordpress installation, should have at least an 'Editor' role
wordpress.passwordThe user's password

for instance

wordpress.url='http://myblog.wordpress.org/xmlrpc.php'
wordpress.blogId=0
wordpress.username='myapp'
wordpress.password='grailsrocks'

In wordpress you need to create a user that has at least an 'Editor' role and enable the Remote Publishing through XML-RPC in the "Settings" > "Writing" menu like below:

Scripts

install-wordpress-templates

The tags in this plugin use gsp templates to provide html output. These templates can be installed in grails-app/views/wordpress by running

grails install-wordpress-templates

Tags

The Wordpress plugin currently provides the following tags that provide some content from a wordpress installation.

wordpress:categories

Use

<wordpress:categories />

The result is the category names in <li> elements:

<ul>
  <li>Category 1</li>
  <li>Category 2</li>
…
</ul>

wordpress:recentPosts

Use

<wordpress:recentPosts count="5" />

The result is a list of the 5 most recent posts displaying the post extract like this

<div class="post">
This is a post
</div>
...

The wordpress "more break" (<!-- more -->) is used to distinguish the extract from the rest of the post.

An optional "status" attribute that can take on the following values may be included to filter the types of post included in the output

  • publish
  • draft
  • pending
  • private

wordpress:page

Use

<wordpress:page id="20" />

Will display the content of the page having id 20 in the GSP.

Service

The WordpressService provides an interface for accessing XML-RPC results directly without going through the tag lib.

Currently the following methods are implemented:

getCategories()
getPage(String id)
getPost(String id)
getRecentPosts(int count, String status = 'publish')

Version History

  • 0.1.2 - Implement tag output through templates, implement install-wordpress-templates script to allow customization of tag output
  • 0.1.1 - Fix issue with getRecentPosts() returning draft posts, implement caching of posts
  • 0.1 - Initial release

Roadmap

Issues and improvements for this plugin are maintained here on Codehaus JIRA.