我必须得到特定的页面内容(如第(12)页)
我用过:
<?php $id=47; $post = get_page($id); echo $post->post_content; ?>
Run Code Online (Sandbox Code Playgroud)
与qtranslate兼容的工作很好的execpt它返回法语和英语文本
但循环很好,只返回良好的语言版本
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<div id="post">
<?php the_content(); ?>
</div> <!-- .post -->
Run Code Online (Sandbox Code Playgroud)
所以问题......如何获取特定的页面内容以确保循环...
men*_*mam 144
我已经回答了我自己的问题.打电话apply_filter,你去.
<?php
$id=47;
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
Run Code Online (Sandbox Code Playgroud)
Ale*_*lex 37
按页面名称获取页面内容:
<?php
$page = get_page_by_title( 'page-name' );
$content = apply_filters('the_content', $page->post_content);
echo $content;
?>
Run Code Online (Sandbox Code Playgroud)
我用过这个:
<?php echo get_post_field('post_content', $post->ID); ?>
Run Code Online (Sandbox Code Playgroud)
这更简洁:
<?= get_post_field('post_content', $post->ID) ?>
Run Code Online (Sandbox Code Playgroud)
通过id获取内容的简单快捷方式:
echo get_post_field('post_content', $id);
Run Code Online (Sandbox Code Playgroud)
如果您想要格式化内容:
echo apply_filters('the_content', get_post_field('post_content', $id));
Run Code Online (Sandbox Code Playgroud)
适用于页面,帖子和自定义帖子.
仅复制并粘贴此代码即可获取您的页面内容。
<?php
$pageid = get_the_id();
$content_post = get_post($pageid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
185820 次 |
| 最近记录: |