0

我正在开发一个 Wordpress 主题。头版上的一个部分标题为“新闻”。在该部分中,用户应该能够自己插入信息(我将创建一个名为 news.php 的单独文件,该文件将 php 包含在标记中),但我还希望在用户发布后自动更新内容。

例如,如果用户写了一篇新文章,我希望新闻部分自动更新为如下内容:

写了一篇新帖子,在这里找到它(“这里”是指向帖子网址的超链接)。

编辑让我尝试提供更多细节,以便更清楚。新闻部分将是一个无序列表。因此:

<ul>
<li>
News item 1
</li>
<li>
News item 2
</li>
</ul>

我希望用户能够将内容添加到新闻部分,也就是制作新的新闻项目,但是使用 Wordpress 的可视化编辑器,这样用户就不必理解代码,也不必复制/粘贴LI。

此外,每当发布新帖子时,我希望它显示为:

“新帖子已发布,请在此处找到”,其中“此处”是链接到该帖子的超链接。

这有可能实现吗?

谢谢,阿米特

4

2 回答 2

2

制作一个名为“新闻”的类别或自定义帖子类型,因此当用户创建新帖子但希望它位于“新闻”部分时,他所要做的就是单击类别“新闻”。您还可以创建自定义帖子类型,仅用于“新闻”并具有自定义分类法等。

Then when you want to print the News post in your theme, write use the query post function and limit the loop to "category_name=news"

于 2010-07-28T13:05:17.343 回答
1

如果我理解正确,你需要写这样的东西:

<?php
query_posts(array('posts_per_page' => 1));
the_post();
?>
A new post was written, find it <a href="<?php echo the_permalink();?>">here</a>

最新消息列表

<?php
query_posts(array('posts_per_page' => 6));
?>
<ul>
<?php $count=0; if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><a href="<?php echo the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
</ul>
于 2010-07-28T12:53:54.283 回答