Skip to content

Instantly share code, notes, and snippets.

@pije76
Created July 27, 2013 02:19
Show Gist options
  • Save pije76/6093396 to your computer and use it in GitHub Desktop.
Save pije76/6093396 to your computer and use it in GitHub Desktop.
see the articles/posts above the subcategories of article-directory
<?php get_header(); ?>
<?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?>
<?php if (have_posts()) : ?>
<?php
$order = "&orderby=cost&order=DESC";
$s2 = ' selected="selected"';
if ($_POST['select'] == 'title') { $order = "&orderby=title&order=ASC"; $s1 = ' selected="selected"'; $s2 = ''; }
if ($_POST['select'] == 'newest') { $order = "&orderby=cost&order=DESC"; $s2 = ' selected="selected"'; }
if ($_POST['select'] == 'oldest') { $order = "&orderby=cost&order=ASC"; $s3 = ' selected="selected"'; $s2 = ''; }
?>
<form method="post" id="order">
<?php _e('Sort by', 'article-directory'); ?>:
<select name="select" onchange='this.form.submit()'>
<option value="title"<?=$s1?>><?php _e('Title', 'article-directory'); ?></option>
<option value="newest"<?=$s2?>><?php _e('Newest', 'article-directory'); ?></option>
<option value="oldest"<?=$s3?>><?php _e('Oldest', 'article-directory'); ?></option>
</select>
</form>
<?php $posts = query_posts($query_string . $order); ?>
<?php while (have_posts()) : the_post(); ?>
<article class="post">
<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<div class="pmeta"><?php the_time(get_option('date_format')); ?> | <?php _e('Author'); ?>: <?php the_author_posts_link(); ?> | <?php _e('Posted in', 'article-directory'); ?> <?php the_category(', ') ?><?php edit_post_link(__('Edit'), ' | ', ''); ?></div>
<div class="entry">
<?php the_excerpt(); ?>
</div>
<div class="ptags"><span class="comments"><?php comments_popup_link(__('No Comments &#187;', 'article-directory'), __('1 Comment &#187;', 'article-directory'), __('% Comments &#187;', 'article-directory')); ?></span> <?php the_tags(__('Tags: ', 'article-directory'), ', ', ''); ?></div>
</article>
<?php endwhile; ?>
<?php kama_pagenavi(); ?>
<?php else : ?>
<p><strong><?php _e('No articles in this category.', 'article-directory'); ?></strong></p>
<?php endif; ?>
<?php if (get_categories('child_of='.$cat.'&hide_empty=0')) { ?>
<h3><?php _e('Subcategories', 'article-directory'); ?>:</h3>
<ul id="childCats">
<?php wp_list_categories('show_count=1&child_of='.$cat.'&hide_empty=0&title_li='); ?>
</ul>
<?php
} else {
$parent = get_category($cat);
if ($parent->parent) {
if (get_categories('child_of='.$parent->parent.'&exclude='.$cat.'&hide_empty=0')) {
?>
<h3><?php $parentCat = get_category($parent->parent); printf(__('Other Subcategories of the "%s" Category', 'article-directory'), $parentCat->cat_name); ?>:</h3>
<ul id="childCats">
<?php wp_list_categories('show_count=1&child_of='.$parent->parent.'&exclude='.$cat.'&hide_empty=0&title_li='); ?>
</ul>
<?php
}
}
}
?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment