Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to make a template page that would display all posts from all categories, in short - every post added to my website. I was googling around and found out that it can be done by using The Loop. The examples were mainly based on Twenty Eleven which is pretty straight-forward. Unfortunately I am using a complex theme and my understanding of PHP is very little... This the website I am developing: http://www.pomorzekultury.pl/ and this is the template page I would like to "adjust" to display everything: http://pastebin.com/5a8fZ3u6 . I hope some of you will make something of this, because as I said eariler I fail understand what is going on here...;)



Edit: The whole code of this PHP file I would like to work on:

<?php /* Blog Style B */

        $i = 1;

        if (have_posts()) : while (have_posts()) : the_post();

        $format = get_post_format();
        $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on');

        $category_data = NULL;

        foreach( ( get_the_category() ) as $category )  {
                        $category_name = $category->cat_name;
                        $category_url = get_category_link($category);
                        $category_data .= '<span class="cb-category"><a href="'.$category_url.'">'.$category_name.'</a></span>';
        $cat_com_url = get_comments_link();

        $cb_custom_fields = get_post_custom();
        if (isset($cb_custom_fields['cb_review_checkbox'][0])) { $cb_review_checkbox = 'on'; } else { $cb_review_checkbox = 'off'; }
        if ($cb_review_checkbox == 'on') { $format = 'review'; }
        $j = $i / 3;

    <article id="post-<?php the_ID(); ?>" class="cb-blog-style-b <?php  if (is_int($j)) {echo 'right-half '; } ?>clearfix<?php if (is_sticky()) echo ' sticky'; ?>" role="article">
                <div class="mask">
                <?php cb_review_thumbnail($post); ?>                        
            <a href="<?php the_permalink(); ?>">
                if ( has_post_thumbnail() ) {
                  } else {
                      echo '<img src="'.get_template_directory_uri().'/library/images/thumbnail-350x200.png" alt="related post">';
               <?php if (false !== $format) {echo '<span class="cb-icon '. $format . '-icon"></span>'; } ?>

        <?php echo $category_data; ?>

        <?php if (get_comments_number() > 0) { ?>
                <a href="<?php echo $cat_com_url; ?>">
                        <p class="cb-comments"><?php echo get_comments_number(); ?></p>
                <?php } ?>

        <h2 class="h4">
                <a href="<?php the_permalink(); ?>">
                  <?php the_title(); ?>

         <?php  if ($cb_meta_onoff == 'on') { ?><p class="cb-byline vcard"><?php printf(__('z dnia <time class="updated" datetime="%2$s" pubdate>%3$s</time>', 'cubell'), cb_get_the_author_posts_link(), get_the_time('Y-m-j'), get_the_time(get_option('date_format')) );  ?></p><?php } ?>

        <div class="cb-excerpt">
            <?php echo cb_clean_excerpt(150, true); ?>

        <div class="cb-bottom-white"></div>
    </article> <!-- end article -->

     <div class="clearfix"></div>    

EDIT No.2:

Maybe listing using archives template would be easier? The archive template loads a view template and the code goes like this:

<?php get_header(); 
$cb_sidebar_position = ot_get_option('cb_sidebar_position', 'cb_sidebar_right'); 

<div id="cb-content" class="wrap clearfix">

    <div id="main" class="<?php if ($cb_sidebar_position == 'cb_sidebar_left'){echo 'left-sidebar';} ?>  clearfix" role="main">

        <?php if (is_day()) { ?>
            <h1 class="archive-title">
                <span><?php _e("Daily Archives:", "cubell"); ?></span> <?php the_time('l, F j, Y'); ?>

        <?php } elseif (is_month()) { ?>
            <h1 class="archive-title">
                <span><?php _e("Monthly Archives:", "cubell"); ?></span> <?php the_time('F Y'); ?>

        <?php } elseif (is_year()) { ?>
            <h1 class="archive-title">
                <span><?php _e("Yearly Archives:", "cubell"); ?></span> <?php the_time('Y'); ?>
        <?php } ?>

        <?php if (have_posts()) { 

                            get_template_part('cat', 'style-b');
             } ?>

    </div> <!-- end #main -->

    <?php get_sidebar(); ?>

</div> <!-- end #cb-content -->

<?php get_footer(); ?>

so get_template_part('cat', 'style-b'); is taking care of layout but function/reference to all posts needs to be added... Any ideas? :)

share|improve this question
add comment

1 Answer

Please call header and footer part,may be it is possible that global variables are not initiated without header.

share|improve this answer
Ok, I did it. I called the main wrapper too, so it looks a bit better. But How can posts be displayed> –  Rafał Wyszomirski Jul 15 '13 at 11:18
Sorry,i can not say anything now without look up in theme.You can try <?php the_ID(); ?> to know that post id is there or not OR anything else to know that from where the code is breaking. –  Bindiya Patoliya Jul 15 '13 at 11:30
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.