WordPress 插件在内容页面上输出特定类别调整帮助
我正在使用 WordPress 插件 类别页面 来显示某个类别的最新 5 篇帖子网站的常规内容页面(不是博客页面)。
目前该插件仅限于显示链接到帖子页面的帖子标题。这是一个视频博客类型的网站,我需要该插件来显示帖子标题(就像现在一样)和视频。可能只是告诉脚本显示内容就可以了,但我不知道如何调整它。
这是输出帖子标题的脚本部分:
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;
}
如果有人有任何建议或知道如何提供帮助,请提前致谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的示例中,内容位于 $single->post_content 中。将其添加到
$output
中:$output .= "
";
The content is in $single->post_content in your example. Add it to the
$output
:$output .= "<li><a href='".get_permalink($single->ID)." '>".$single->post_title."**<span class='video'>".$single->post_content."<span>**</a></li>";