下面的代码正确地显示了我选择的页面及其内容和缩写。页面是从WP管理中的主题选项面板中选择的。
我正在努力回想这个标题。目前,它正在响应所有的页面标题。任何帮助都非常感谢!
<?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)."";
}?>再次感谢!
发布于 2012-01-19 23:48:58
要回显单个wordpress页面的标题,可以执行以下wordpress函数
<?php the_title() ?>您还可以在它周围添加一些用于css格式化的html,如下所示->
<h2><?php the_title() ?></h2>祝好运
发布于 2012-01-20 00:15:12
根据食典: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; ?>发布于 2014-04-23 19:22:30
<?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)."";
}?>https://stackoverflow.com/questions/8928869
复制相似问题