This blog is based on Arun Kale’s theme „The Morning After“. Inspired by „The Morning After“ – discussion board, I decided that I am in need for an additional asides section where I can post quotes that make a „free person“ think.
Getting started…
Create the category (Dashboard – Manage – Category – Add New) that should be displayed inside the new section. I called the category „Quotes“.
home.php
Open the home.php file with you theme editor and scroll to
< ?php $catid2 = $wpdb->get_var("SELECT term_ID FROM $wpdb->terms WHERE name='Featured'"); ?>
You insert the following line below to receive the catid of the category „Quotes“.
"SELECT term_ID FROM $wpdb->terms WHERE name='Quotes'"); ?>
Now, you have to exclude the „Quotes“ from Latest and Recent Posts. Therefore, you have to insert ‚ .$catid3. ‚ into the following line of the lastest_post section (code snippet after insertion):
< ?php $the_query = new WP_Query('cat=-' .$catid. ',-' .$catid2. '-' .$catid3. '&showposts=1&orderby=post_date&order=desc');
and into the recent post section (code snippet after insertion):
< ?php $the_query = new WP_Query('cat=-' .$catid. ',-' .$catid2. ',-' .$catid3. '&showposts=5&offset=1&orderby=post_date&order=desc');
Now, it is time to define the section where the quotes should appear. I have done that by inserting the following code below the asides:
<div class="home_asides"><!-- start Quotes -->
<h3 class="mast">Quotes</h3>
<ul class="arrow">< ?php $the_query = new WP_Query('category_name=quotes&showposts=1&orderby=post_date&order=desc'); while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID; ?>
<li>< ?php echo strip_tags(get_the_content(), '<a><em>'); ?> </em></a></li>
< ?php endwhile; ?></ul>
</div>
This code shows the latest post of the „Quotes“ category and uses the „arrow“ design of the asides section.
sidebar.php
The last (optional) step for adding a new asides section to „The Morning After“ is to exclude the category from the category navigation. Therefore, you have to open the sidebar.php in your theme editor and to substitute this:
< ?php $catid2 = $wpdb->get_var("SELECT term_ID FROM $wpdb->terms WHERE name='Featured'"); ?>
< ?php wp_list_categories('title_li=&sort_column=name&show_count=0&
show_last_updated=1&use_desc_for_title=1&exclude=' .$catid. ',' .$catid2. '') ?>
by this:
< ?php $catid2 = $wpdb->get_var("SELECT term_ID FROM $wpdb->terms WHERE name='Featured'"); ?>
< ?php $catid3 = $wpdb->get_var("SELECT term_ID FROM $wpdb->terms WHERE name='Quotes'"); ?>
< ?php wp_list_categories('title_li=&sort_column=name&show_count=0&
show_last_updated=1&use_desc_for_title=1&exclude=' .$catid. ',' .$catid2. ',' .$catid3. '') ?>
DONE!!!
Schreibe einen Kommentar