Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress WordPress Theme Development Adding a Blog to a WordPress Theme A Catch All Archives Page

Anthony Lucio
Anthony Lucio
20,431 Points

How to Category Blog Posts and Author title specificity like example on video?

Archive category page shows:

"Uncategorized Archives - [title of home page] Blog Posts"

Authored blog posts show as:

"[Author name] Author at [title of home page] Blog Posts"

Under "archive.php", I have the following code.

<!-- Primary Column --> <div class="small-12 medium-7 medium-offset-1 medium-push-4 columns"> <div class="primary">

      <div class="leader">
        <h1><?php wp_title(''); ?> Blog Posts</h1>
      </div>

4 Answers

Anthony Lucio
Anthony Lucio
20,431 Points

The code below is what is in the 'archive.php' file. The portion at the very top of this page is conflicting with the content from the video in that it does not produce the same results as the video. How do we change the portion of code to mimic the results in the video?

<?php get_header(); ?>

<section class="two-column row no-max pad"> <div class="small-12 columns"> <div class="row"> <!-- Primary Column --> <div class="small-12 medium-7 medium-offset-1 medium-push-4 columns"> <div class="primary">

      <div class="leader">
        <h1><?php wp_title(''); ?> Blog Posts</h1>
      </div>

        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

          <article class="post">
            <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
            <h2><?php echo strip_tags( get_the_excerpt() ); ?></h2>
            <ul class="post-meta no-bullet">
              <li class="author">
                  <span class="wpt-avatar small">
                    <?php echo get_avatar( get_the_author_meta( 'ID' ), 24 ); ?>
                  </span>
                  by <?php the_author_posts_link(); ?>
              </li>
              <li class="cat">in <?php the_category( ', ' ); ?></li>
              <li class="date">on <?php the_time( 'F j, Y'); ?></li>
            </ul>
            <?php if( get_the_post_thumbnail() ): ?>
            <div class="img-container">
              <?php the_post_thumbnail('large'); ?>
            </div>
            <?php endif; ?>
          </article>

        <?php endwhile; else : ?>

            <p><?php _e( 'Sorry, no pages found.' ); ?></p>

        <?php endif; ?>

    </div>
  </div>

  <!-- Secondary Column -->
  <div class="small-12 medium-4 medium-pull-8 columns">
    <div class="secondary">
          <h2 class="module-heading">Sidebar</h2>
    </div>
</div>

</div> </section>

<?php get_footer(); ?>

Kevin Korte
Kevin Korte
28,149 Points

Okay, so what is it doing, or not doing. I've watched the video so I see what it should be doing, so what's going on specifically?

Anthony Lucio
Anthony Lucio
20,431 Points

the video displays this (http://f.cl.ly/items/1r453f1Y1c0N0m293S2e/treehouse%20version.PNG)

my blog's uncategorized archive shows this(http://f.cl.ly/items/2G0g072L0Y1i0T1d2E2B/myviewofblogarchive.PNG)

my blog's author archive shows this(http://f.cl.ly/items/0Y370I0Y3Q1W2Z2d0x1R/myviewofblogarchiveauthor.PNG)

ps: Thank you ahead of time for your assistance. :-)

Yudi Haryasa
Yudi Haryasa
1,612 Points

It's because we use wp_title('') function to display the title. And we can setting how the title displayed in the admin setting menu.

Kevin Korte
Kevin Korte
28,149 Points

The code is on the screen at the 1:23 mark. You could also download the project files.

Anthony Lucio
Anthony Lucio
20,431 Points

The information at 1:23 is the exact same information as what was posted above and the information in the project files is the exact same code that is above.

Kevin Korte
Kevin Korte
28,149 Points

I'm very confused than because no, it's not the exact same.

All I see is your code stops after the .leader div. Your question is how to get the category blog posts and author title specificity like the video. None of that code exists in your post above. From the archive.php file, that code that shows the blog posts and author title is this

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

              <article class="post">
                <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                <h2><?php echo strip_tags( get_the_excerpt() ); ?></h2>
                <ul class="post-meta no-bullet">
                  <li class="author">
                      <span class="wpt-avatar small">
                        <?php echo get_avatar( get_the_author_meta( 'ID' ), 24 ); ?>
                      </span>
                      by <?php the_author_posts_link(); ?>                    
                  </li>
                  <li class="cat">in <?php the_category( ', ' ); ?></li>
                  <li class="date">on <?php the_time('F j, Y'); ?></li>
                </ul>    
                <?php if( get_the_post_thumbnail() ) : ?>
                <div class="img-container">
                  <?php the_post_thumbnail('large'); ?>
                </div>  
                <?php endif; ?>             
              </article>


            <?php endwhile; else : ?>

              <p><?php _e( 'Sorry, no pages found.' ); ?></p>

            <?php endif; ?>

I believe that's what you wanted.