以下代码会正确显示我选择的网页,内容和缩写。该页面是从WP Admin。中的主题选项面板中选择的。
我正在努力回应这个头衔。目前它正在回应所有页面标题。任何帮助太多了!
<?php
$blockwho = get_option('good_blockwho');
$homeblockwho = get_pages ('post_name='.$blockwho); ?>
<?php foreach ($homeblockwho as $hbw) {
$content = $hbw->post_content;
$title = $hbw->post_title;
apply_filters('the_content', $content);
echo "<h2><span>".$title."</span></h2>";
echo "".do_shortcode($content)."";
}?>
再次感谢!
答案 0 :(得分:0)
回显一个单一的wordpress页面的标题,你做这个wordpress功能
<?php the_title() ?>
你也可以用一些html来包围css格式,例如follow-&gt;
<h2><?php the_title() ?></h2>
祝你好运
答案 1 :(得分:0)
根据食典委:http://codex.wordpress.org/Function_Reference/get_pages
“post_name”不是get_pages的参数,它是“sort_column”的可能值。
尝试以下方法:
<?php
global $post;
$blockwho = get_option('good_blockwho');
$page = get_page_by_title($blockwho);
$myposts = get_posts('post_type=page&p='$page->ID);
foreach($myposts as $post) :
setup_postdata($post);
?>
<?php the_title(); ?>
<?php endforeach; ?>
答案 2 :(得分:0)
<?php
$blockwho = get_option('good_blockwho');
$homeblockwho = get_pages ('post_name='.$blockwho); ?>
<?php foreach ($homeblockwho as $hbw) {
$content = $hbw->post_content;
$title = $hbw->post_title;
apply_filters('the_content', $content);
echo "<h2><span>".$homeblockwho ->post_title."</span></h2>";
echo "".do_shortcode($content)."";
}?>
答案 3 :(得分:0)
如果你想只回显一页,这应该可以解决问题:
<?php
$blockwho = get_option('good_blockwho');
$page = get_post($blockwho);
$content = $page->post_content;
apply_filters('the_content', $content);
echo "<h2><span>".$page->post_title."</span></h2>";
echo "".do_shortcode($content)."";
答案 4 :(得分:-1)
首先我建议将实际的页面/帖子ID存储在选项表而不是它的名称中,你仍然可以向用户显示页面标题,只需要一个带有选项值为ID的下拉框
您是否检查过j-man86的$ page-&gt; ID?答案实际上是否返回了正确的ID?
假设存储的选项是页面ID而不是页面标题,则以下内容将起作用
$page = get_page(get_option('good_blockwho'));
$title = $page->post_title;
$content = apply_filters('the_content', $page->post_content);