Php 获取子内容
我使用下面的方法来获取儿童标题和内容。每个孩子在内容编辑器中都有一个库和一个短代码,但我只得到库而不是短代码。这与短代码无关,而是与内容有关,因为我试图在库后的内容中添加一些段落,但它没有显示出来Php 获取子内容,php,wordpress,Php,Wordpress,我使用下面的方法来获取儿童标题和内容。每个孩子在内容编辑器中都有一个库和一个短代码,但我只得到库而不是短代码。这与短代码无关,而是与内容有关,因为我试图在库后的内容中添加一些段落,但它没有显示出来 <?php $pages = get_pages('child_of='.$page->ID.'&sort_order=asc&number=3&sort_column=menu_order&parent='.$page->ID); foreach($
<?php $pages = get_pages('child_of='.$page->ID.'&sort_order=asc&number=3&sort_column=menu_order&parent='.$page->ID);
foreach($pages as $page) {
$content = $page->post_content;
$content = apply_filters('the_content', $content);
?>
<div class="span4">
<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
<?php echo $content ?>
</div>
我认为
$content=apply_过滤器('the_content',$content)代码>基本上是剥离部分内容。知道它为什么不显示短代码吗?我就是这样解决的:
<?php
/*
Template Name: home
*/
get_header(); ?>
<?php $counter = 1 ?>
<div class="row-fluid">
<?php
$args = array(
'child_of' => 4,
'parent' => 0,
'post_type' => 'page',
'post_status' => 'publish'
);
$childrens = query_posts('showposts=3&post_parent=4&post_type=page&orderby=menu_order&order=DESC');
foreach ( $childrens as $children ) :
query_posts('showposts=3&post_parent='.$children->ID.'&post_type=page&orderby=menu_order&order=DESC');
if ( have_posts ) :
while ( have_posts() ) : the_post();
?>
<div class="span4">
<h2>
<?php the_title(); ?>
</h2>
<?php the_content(); ?>
</div>
<? if ($counter % 3 == 0): ?>
<div id="content" class="row-fluid"></div>
</div>
<div class="row-fluid">
<?php endif; ?>
<?php $counter++; ?>
<?php
endwhile;
endif;
endforeach;
?>
</div>
<?php get_footer(); ?>
我就是这样解决的:
<?php
/*
Template Name: home
*/
get_header(); ?>
<?php $counter = 1 ?>
<div class="row-fluid">
<?php
$args = array(
'child_of' => 4,
'parent' => 0,
'post_type' => 'page',
'post_status' => 'publish'
);
$childrens = query_posts('showposts=3&post_parent=4&post_type=page&orderby=menu_order&order=DESC');
foreach ( $childrens as $children ) :
query_posts('showposts=3&post_parent='.$children->ID.'&post_type=page&orderby=menu_order&order=DESC');
if ( have_posts ) :
while ( have_posts() ) : the_post();
?>
<div class="span4">
<h2>
<?php the_title(); ?>
</h2>
<?php the_content(); ?>
</div>
<? if ($counter % 3 == 0): ?>
<div id="content" class="row-fluid"></div>
</div>
<div class="row-fluid">
<?php endif; ?>
<?php $counter++; ?>
<?php
endwhile;
endif;
endforeach;
?>
</div>
<?php get_footer(); ?>
打印时,短代码是否仍在内容中?或者短代码消失了,没有被它应该被替换的内容替换?(我想确保我完全理解你的问题。)从字面上说,我在我的内容中有这个:[gallery ids=“181,22,28”][next_page][previous_page],在加载页面时的html中,我只有gallery,没有其他内容。打印内容时,短码仍然存在吗?或者短代码消失了,没有被它应该被替换的内容替换?(我想确保我完全理解你的问题。)从字面上说,我在我的内容中有这个:[gallery id=“181,22,28”][next_page][previous_page],在html中,当页面加载时,我只有gallery,没有其他内容