获取页面内容的正确方法 [英] Proper way to get page content
本文介绍了获取页面内容的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须获取特定的页面内容(例如 page(12))
我用过:
post_content;?>
很好地执行与翻译的兼容性,它返回法语和英语文本
但是循环没问题,只返回好的语言版本
<?php if(have_posts()) : while(have_posts()) : the_post();?><div id="post"><?php the_content();?>
<!-- .post -->
所以问题....如何在循环中获取特定页面内容...
解决方案
我已经回答了我自己的问题.调用 apply_filter
就可以了.
post_content);回声$内容;?>
I have to get specific page content (like page(12))
I used that :
<?php $id=47; $post = get_page($id); echo $post->post_content; ?>
Work nice execpt for compatibility with translations, it returns both French and English text
But the loop is fine, return only the good language version
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<div id="post">
<?php the_content(); ?>
</div> <!-- .post -->
So the question.... HOW to get a specific page content inside the loop...
解决方案
I've answered my own question. Call apply_filter
and there you go.
<?php
$id=47;
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
这篇关于获取页面内容的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文