1

我正在使用以下内容来获取子标题和内容。每个孩子在内容的内容编辑器中都有一个画廊和一个短代码,但我只得到画廊而不是短代码。这与短代码无关,而是与内容有关,因为我试图在图库后面的内容中添加一些段落,但它没有显示出来。

<?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_filters('the_content', $content);基本上是剥离了部分内容。知道为什么它不显示短代码吗?

4

1 回答 1

1

这就是我解决它的方法:

<?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(); ?>
于 2013-01-28T23:11:27.150 回答