[wp-hackers] category URL's and SEO ranking
Shasta Willson
shastaw at gmail.com
Tue Jun 19 16:53:16 UTC 2012
I sometimes create a category page which displays any posts in the
category (but NOT posts in the children), and then links to the
children categories. So far as I can tell this removes any path to
get to the subcategory posts from the parent category.
e.g. http://pprc.org/testing123/testbed/index.php/category/networking/
(After this goes live the testing parts of the URL will go away.)
You can use http://codex.wordpress.org/Template_Tags/in_category for
testing if the post is actually in THIS category (not a subcategory)
to decide whether to post it. (Note if the client checks the parent
category then it's in it too.)
<?php
$cat_id = get_query_var('cat');
$catlist = get_categories('child_of=' . $cat_id);
if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if (in_category($cat_id)) : ?>
<div class="one_synopsis">
<div class="cat_headline">
<h1 class="storytitle"><a href="<?php echo get_permalink(); ?>"><?php
the_title(); ?></a></h1>
<?php if (is_category('Blog')) : ?>
<b><i><?php echo get_the_date( $d ); ?></b></i>
<?php endif; ?>
</div>
<div class="storycontent">
<?php the_advanced_excerpt('length=50&use_words=1&no_custom=0&exclude_tags=img,p,strong,h1,h2,h3,a,i,b,
em'); ?>
</div>
<div class="storyimage">
<?php if( has_post_thumbnail() )
{ the_post_thumbnail('carousel_thumbnail'); } ?>
</div>
<div style="clear:both;"></div>
</div>
<?php endif; ?>
<?php endwhile; else: ?>
<p><?php _e('Page not found.'); ?></p>
<?php endif; ?>
<?php if ($catlist) {
foreach ($catlist as $category) {
echo '<div class="subcategory"><h1>Related Topic: <a href="' .
get_category_link( $category->term_id ) . '" title="' . sprintf( __(
"View all posts in %s" ), $category->name ) . '" ' . '>' .
$category->name.'</a></h1> ';
echo '<p>'. $category->description . '</p> </div>';
}
} ?>
- Shasta
More information about the wp-hackers
mailing list