WordPress plugin to output a certain category on content page tweak help
Posted
by
talkingD0G
on Stack Overflow
See other posts from Stack Overflow
or by talkingD0G
Published on 2010-12-31T07:38:02Z
Indexed on
2010/12/31
7:54 UTC
Read the original article
Hit count: 276
I'm using WordPress plugin Category Page to display the most recent 5 posts from a certain category on a regular content page (not the blog page) of a website.
Right now the plugin is limited to display the post title linked to the post page. This is a video blog type site and I need the plugin to display the post title (as it does now) with the video as well. Probably just telling the script to show the content would work but I don't know how to tweak it.
This is the section of the script that is outputting the post title:
function page2cat_content_catlist($content){
global $post;
if ( stristr( $content, '[catlist' )) {
$search = "@(?:<p>)*\s*\[catlist\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches)) {
if (is_array($matches)) {
$title = get_option('p2c_catlist_title');
if($title != "") $output = "<h4>".$title."</h4>"; else $output = "";
$output .= "<ul class='p2c_catlist'>";
$limit = get_option('p2c_catlist_limit');
foreach ($matches[1] as $key =>$v0) {
$catposts = get_posts('category='.$v0."&numberposts=".$limit);
foreach($catposts as $single):
$output .= "<li><a href='".get_permalink($single->ID)." '>".$single->post_title."</a></li>";
endforeach;
$search = $matches[0][$key];
$replace= $output;
$content= str_replace ($search, $replace, $content);
}
$output .= "</ul>";
}
}
}
return $content;
}
If anyone has any advice or knows how to help thanks in advance!
© Stack Overflow or respective owner