Support » Themes and Templates » Category/Date heading on Very Simple theme

  • I would like all of my category and date archive views to have just under the main header but before the date of the first entry a prominent sub-head saying:

    You are browsing [Category/Date] – Back to Home

    How would I implement that?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Check out how the archive.php is done in the Default theme.

    Ok, that means the following code:

    <?php if (have_posts()) : ?>

    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    <?php /* If this is a category archive */ if (is_category()) { ?>
    <h2 class="pagetitle">Archive for the '<?php echo single_cat_title(); ?>' Category</h2>

    <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>

    <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    <h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>

    <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    <h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>

    <?php /* If this is a search */ } elseif (is_search()) { ?>
    <h2 class="pagetitle">Search Results</h2>

    <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    <h2 class="pagetitle">Author Archive</h2>

    <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    <h2 class="pagetitle">Blog Archives</h2>

    <?php } ?>

    You can change things here like ‘archive for the’ and change those to ‘you are browsing’.
    Where to put it? Just under <div class=”main”> will be where you like it I think.

    And see this for another (briefer) option:

    http://wordpress.org/support/topic.php?id=31005#post-175230

    OK – but Very Simple has no archive or archives.php files as standard. What do I do to make the archives be changed in just that way and no other? Make a copy of index.php with the new header and call it archive.php? That would surely be too easy 😉

    It should only display in the cases the code says: if it’s a certain category, a certain day, a certain monts, etc. the user is browsing.

    derb: To reinforce what dissurion said, consider that the code above goes into the sidebar.php (or the sidebar/menu section of one’s index.php or other template). Based on the conditional tags used (is_category(), is_author(), etc), WordPress is able to decide when a specific element is to be displayed. It has nothing to do with the template per se.

    Well there isn’t a <div class=”main”> – I tried putting something like the above in at <div class=”content> – above the existing line:
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?><?php the_date(”,'<div class=”dateStamp”>’,'</div>’); ?>

    And the page went completely blank! Worse, I backed up the wrong file so I couldn’t roll back the changes and when I tried removing the changes I made manually I still get a blank page. Yikes!

    (The site in question is http://blog.org/wp/ by the way – and the page that emerges (in its entirety) is <html><body></body></html>

    Ok, can you copy and past here (put it between backtics) you’re complete index.php file of your theme.

    Probably it’s a better idea to paste not here in the forum but at http://paste.uni.cc

    Here it is (as I tried to fix it):
    http://paste.uni.cc/6931

    I saved the file and tested it locally. It worked, except two errors were noted, maybe because of the pasting. On line 231 and 233 you should delete the combination of strange characters and replace them by a space (those serie ending on 352). It should be:

    ´class=”categories”><?php _e(‘Categories:’); ?> ´
    and
    ´ method=”get”><?php dropdown_cats(); ?><input ´

    Getting rid of those extraneous tags seems to have done the trick but I can’t figure out where to stick in the script provided in order to make the navigation directions turn up at the top of the page – reintroducing them causes the same problem to reappear… Guess I will give up on that for the time being!

    Try to insert ´<?php if (have_posts()) { ?>

    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    <?php /* If this is a category archive */ if (is_category()) { ?>
    <h2 class=”pagetitle”>Archive for the ‘<?php echo single_cat_title(); ?>’ Category</h2>

    <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    <h2 class=”pagetitle”>Archive for <?php the_time(‘F jS, Y’); ?></h2>

    <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    <h2 class=”pagetitle”>Archive for <?php the_time(‘F, Y’); ?></h2>

    <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    <h2 class=”pagetitle”>Archive for <?php the_time(‘Y’); ?></h2>

    <?php /* If this is a search */ } elseif (is_search()) { ?>
    <h2 class=”pagetitle”>Search Results</h2>

    <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    <h2 class=”pagetitle”>Author Archive</h2>

    <?php /* If this is a paged archive */ } elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) { ?>
    <h2 class=”pagetitle”>Blog Archives</h2>

    <?php } } ?>´

    right below ´<div class=”content”>´

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Category/Date heading on Very Simple theme’ is closed to new replies.