wordpress - 将静态内容添加到 Wordpress 帖子页面?

标签 wordpress blogs

关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。












想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。

3年前关闭。




Improve this question




我知道我的 Wordpress 主页有一个静态页面。我还有一个名为“Rate Entries”的页面作为我的博客页面。在向我的客户展示了这个,然后向她展示了 Wordpress 的管理部分后,她开始在 中输入一个段落。页面>>所有页面>>“评价条目”>>编辑 .

众所周知,这里的大问题是,如果“评分条目”是我的帖子页面,则该页面内容不会显示在那里,只显示帖子。有没有办法将该页面内容添加到帖子页面的顶部?我曾希望找到一个插件来做到这一点,但无济于事。

最佳答案

假设您已经为 Wordpress 后端(设置 > 阅读)中的帖子设置了自定义页面,您只需要在 中添加几行代码即可。 index.php 文件中的主题。像这样:

//grab the id of the page set in the backend 
$posts_page_id = get_option('page_for_posts');

//grab the post object related to that id
$posts_page = get_post($posts_page_id);

//display the content if any
if( $posts_page->post_content ){
    echo wpautop( $posts_page->post_content ); //uses wpautop to automatically add paragraphs
}

在您的情况下,您可以添加代码以显示此代码下方的循环。

希望这可以帮助!

关于wordpress - 将静态内容添加到 Wordpress 帖子页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13589288/

相关文章:

php - 如何在 wordpress 中使用帖子 ID 获取帖子缩略图?

php - 如何从 get_page_link() 获取 HTTPS URL?

java 库来准备用户评论以在 web 上显示?

routing - 更改 Ghost 博客的默认路由

jquery - 如何在同位素图像上添加文字?

GitHub 页面 : How can I wrap text around an image?

仅在帖子中使用 Css,wordpress

Wordpress 插件安装 - 无法连接到 FTP 服务器 - 最安全的解决方案?

php - 为什么 the_title() 过滤器也应用于菜单标题?

html - 蓝色燃烧效果 - 他们是怎么做到的?