th_content output does not appear
-
Hi,
I’m trying this a couple of hours. But It doesn’t work out, so here I am and ask for your advice :-).
The code below shows the category and lists the post of it. But I want, that it shows the whole post (the_content();). But I can’t figured out why it does not work. Because the “get_the_title” variable works fine… See the “$posts_list” part.
And I would like that list post from a specified category (+ child categories), is that possible? Someones got an idea?
Thanks in advanced!
<?php wp_list_categories( array( 'walker' => new Walker_Category_Posts(), ) ); class Walker_Category_Posts extends Walker_Category { function start_el(&$output, $category, $depth, $args) { $this->category = $category; parent::start_el($output, $category, $depth, $args); } function end_el(&$output, $page, $depth, $args) { if ( 'list' != $args['style'] ) return; $posts = get_posts( array( 'cat' => $this->category->term_id, 'numberposts' => 100, ) ); if( !empty( $posts ) ) { $posts_list = '<ul>'; foreach( $posts as $post ) while (have_posts()): the_post(); $posts_list .= '<li>' . get_the_title( $post->ID ).the_content();.'</li>'; $posts_list .= '</ul>'; } else { $posts_list = ''; } $output .= "{$posts_list}</li>\n"; } } ?>
- The topic ‘th_content output does not appear’ is closed to new replies.