在模板中显示特定页面

时间:2014-04-27 19:02:26

标签: wordpress

我有点陷入Wordpress。

这就是我想要做的,我想在模板页面中显示特定的内容页面。

get_the_ID();

我有两个值

in property-status / en-ventes /:79

in property-status / en-location /:93

它总是显示页面ID 313,用于slug" en-ventes"它很好,但我想显示slug" en-location"的页面ID 313。

            <br />
            <?php  
            $idpage = get_the_ID(); 
            if($idpage = '79'){
            $my_query = new WP_Query('page_id=302');
            }
            else {
            $my_query = new WP_Query('page_id=313');
            }
            $arg= array($my_query);  
            ?> 

            <?php if (have_posts()) : while ($my_query->have_posts()) : $my_query->the_post();?>
            <?php the_content(); ?>
            <?php endwhile; endif; ?>

1 个答案:

答案 0 :(得分:0)

我不太清楚你需要什么,但是,让我们试试:

$my_postid = 12;//This is page id or post id
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;

echo get_post_field('post_content', $post_id);

(你需要定义de post_id ^)

$id=74; //change
$post = get_post($id);
$title = apply_filters('the_title', $post->post_title);
echo $title;
$content = apply_filters('the_content', $post->post_content);
echo $content;

check this以及this

干杯。

相关问题