Tag Archive for categories

Organize WordPress Category Archive Listing by Subcategory

<?php $categories = get_categories("child_of=17"); foreach ($categories as $cat) { ?>
<div class="genre_subcat">
<?php query_posts("cat=$cat->cat_ID&showposts=-1&order=ASC&orderby=name"); ?>
<h2><?php single_cat_title(); ?></h2>
<small><?php echo category_description($cat->cat_ID); ?></small>
<?php while (have_posts()) : the_post(); ?>
<div class="post">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to
<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<p class="postdate"><?php the_time('F jS, Y') ?></p>
<?php the_content(); ?>
<p class="postmetadata">Posted in <?php the_category(', ') ?> |
<?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
</div>
<?php endwhile; ?>
</div>
<?php }?>

source

Exclude WordPress Categories on Secondary Front Pages

<?php if ( is_home() ) {
query_posts("paged=$paged&cat=-3");
}
while (have_posts()) : the_post(); ?>

source

Pull the Category Description ONLY if a description is available.

<?php if (strlen(trim(category_description())) > 0 && trim(category_description()) != "<br />") {
echo "<div id='catdesc'>";
echo category_description();
echo "</div>";
}
?>

source

Drupal view to create a list of category terms

$view = new stdClass();
$view->name = 'Categories';
$view->description = 'List of categories with number of articles posted in each category.';
$view->access = array (
0 => '1',
1 => '2',
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = 'Browse Articles';
$view->page_header = 'Browse articles by category.';
$view->page_header_format = '1';
$view->page_footer = '';
$view->page_footer_format = '1';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'teaser';
$view->url = 'articles';
$view->use_pager = TRUE;
$view->nodes_per_page = '100';
$view->block = TRUE;
$view->block_title = 'Categories';
$view->block_header = '';
$view->block_header_format = '1';
$view->block_footer = '';
$view->block_footer_format = '1';
$view->block_empty = '';
$view->block_empty_format = '1';
$view->block_type = 'list';
$view->nodes_per_block = '25';
$view->block_more = TRUE;
$view->block_use_page_header = FALSE;
$view->block_use_page_footer = FALSE;
$view->block_use_page_empty = FALSE;
$view->sort = array (
);
$view->argument = array (
array (
'type' => 'taxletter',
'argdefault' => '6',
'title' => '%1',
'options' => '',
'wildcard' => '',
'wildcard_substitution' => '',
),
);
$view->field = array (
array (
'tablename' => 'node',
'field' => 'title',
'label' => '',
'handler' => 'views_handler_field_nodelink',
'sortable' => '1',
'options' => 'link',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
'options' => '',
'value' => '1',
),
);
$view->exposed_filter = array (
);
$view->requires = array(node);
$views[$view->name] = $view;

source

Categorie Entries, semantic way

{exp:weblog:categories weblog="training" style="linear"}
<h3>{category_name}</h3>
<ul>
{exp:weblog:entries category="{category_id}" }
<li><a href="#" title="">{title}</a></li>
{/exp:weblog:entries}
</ul>

{/exp:weblog:categories}

source

Grab category name

<? $cat = get_the_category(); $cat = $cat[0]; echo $cat->cat_name;?>

source