WordPress Plugin: List category posts

November 18, 2011 by
Filed under: WordPress 

One of my client sites that I consult for, CopperTalk (www.coppertalk.org), through Palmer Productions Group has a custom home page with top posts for various categories. I used the List category posts plugin, by Fernando Briano, to accomplish this task.

Soon after a request was made for displaying an excerpt of the latest post from one category as a headline news (Coppertalk News). The displayed content needed to include more than what the post excerpt option supports. Besides, the editors do not use the excerpt option anyway. This looked like a go with the List category posts plugin except for one thing. The plugin does not factor in the <!–more–> tag for cutting off the post on the teaser portion.  It was displaying the full post.

I found the get_content() function in the CatList.php file of the plugin code and looked up how WordPress handles the <!–more–> tag. Some notes in the plugin code mentioned this issue in a ToDo list and a link to a blog post that further addresses the issue. The following code enhancement did the trick:

$beforeMore = get_extended($lcp_content);
$lcp_content = wpautop($beforeMore['main']);

These two lines were placed toward the top of the function and just after the $lcp_content variable is set:

$lcp_content = $single->post_content;

I emailed Fernando Briano the code snippet in hopes that a future plugin update will include this or provide a yes/no argument for the more tag.

Comments

Comments are closed.