Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS WordPress: Posts from Categories on a Page Re: WordPress: Posts from Categories on a Page

#92738
dfazman
Member

Thanks, Doc. I’ve already resigned myself to that approach, but I’m really struggling with it. I’m not a complete idiot fortunately, I just have never been taught to code. It all looks like a logic statement to me, I just don’t know what “things I can say” to make the code work.

I found this code that I’m putting in my custom functions:

function my_page_of_posts() {
if (is_page('833')) {
$custom_loop = new WP_Query('posts_per_page=5&cat=9');
echo '
    ';
    if ( $custom_loop->have_posts() ) : while ( $custom_loop->have_posts() ) : $custom_loop->the_post();
    echo '
  • ' . get_the_title() . ' ( ';
    comments_number('0', '1', '%');
    echo ' )
  • ';
    endwhile;
    wp_reset_query();
    endif;
    echo '
';
}
}
add_action('thesis_hook_after_content','my_page_of_posts');

It works like a charm, and I even figured out how to get my page number and category number plugged in. The problem is the output. I don’t know what “echo” means, can’t figure out what to put there (or remove) to get the output I want. It’s funny – I just want every post in a category, complete, just like the normal loop. Not links to posts or an ordered list. Just toss everything in there! Basic, right? Can you assist?

– B