我有我这样的逻辑,但我不能在我的wordpress上实现我是这个平台的新手。从不同的slu get中获得不同的页面
- 会从不同的蛞蝓不同的页面
- 显示页面标题,并从slug1
- 显示内容的页面标题,并从slug2
- 显示页面标题,并从slug3 内容的内容
总而言之,它们将显示在单个页面上。
我有我这样的逻辑,但我不能在我的wordpress上实现我是这个平台的新手。从不同的slu get中获得不同的页面
总而言之,它们将显示在单个页面上。
从ID而不是页面获取页面会更好,即使它们被称为“永久链接”,您仍然可以更改它们,然后您还必须更新代码,这是一个当然是痛苦。
我建议您为您创建一个模板页面,当您完成后,您可以查询模板中的多个帖子/页面。
您可以创建这样一个模板:
<?php
/*
Template Name: Snarfer
*/
?>
之后,你可以查询不同的岗位是这样的:
$query = new WP_Query('page_id=7'); //this will get the page with teh ID 7
while ($query -> have_posts()) : $query -> the_post();
//query the page data here like the_content(), the_title();
endwhile;
如果你想为你的所有查询页面相同的风格,那么你最好用post__in
变量查询。了解更多关于此不同的选择:https://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
此处详细了解自定义模板:http://codex.wordpress.org/Theme_Development#Custom_Page_Templates
我才意识到,我没有使用正确的方法。我刚刚通过显示由他们的ID给出的3个帖子正确
<?php
$postslist = get_posts('include=120,122,124&orderby=ID&order=ASC');
foreach ($postslist as $post) : setup_postdata($post); ?>
<h3><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h3>
<p><?php the_excerpt(); ?></p>
<?php endforeach; ?>
正如你所说,你是这个平台的新手,你有没有得到你的术语是正确的?你的意思是''页面''还是你想说''帖子“'? – krembo99 2013-04-25 02:28:59
hmmmn ..这些是网页,将显示在一个页面.. 得到这些网页..我认为他们的slu to是关键。也许我会首先声明slu .. ......在wordpress上怎么做? – 2013-04-25 02:42:37
slu are通常是根据你的[固定链接](http://codex.wordpress.org/Settings_Permalinks_Screen)的结构来自动标题, – 2013-04-25 03:08:23