Question

i am creating a theme which consists of two pages, blog and portfolio. therefore i have categories which related to the portfolio posts (ie. web design, graphic design) and categories relating to the blog posts (ie. tutorials, todos)

i have two pages (/blog and /portfolio), in each, i would like to show the list of categories related on to the specific types

(i may not be clear) so this is an example:

all categories: cat1, cat2, cat3, cat4, cat5,cat6

for portfolio: 
<ul>
<li><a>cat1</a></li>
<li><a>cat2</a></li>
<li><a>cat3</a></li>
</ul>

for blog:
<ul>
<li><a>cat4</a></li>
<li><a>cat5</a></li>
<li><a>cat6</a></li>
</ul> 

so is there a way to split them like that

thanks

Was it helpful?

Solution

You can use wp_list_categories() method in your template, this method takes an "exclude" or "exclude_tree" parameter, which allows you to exclude blog categories in the first list, and portfolio in the second.

http://codex.wordpress.org/Template_Tags/wp_list_categories

OTHER TIPS

Here is the method I use to control which category of posts shows on which pages of a WordPress blog. I insert this line of code into the page.php file, just before the loop is called:

<?php
$catID = 0;
if (is_page('videos')) {
 $catID=3;
} elseif (is_page('music')) {
 $catID=4;
}
 elseif (is_page('poetry')) {
 $catID=5;
}

if ($catID) {
 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
 query_posts("cat=$catID&amp;paged=$paged");
} ?>

Note: The names in parentheses after "is_page=" are the page slugs, not the page titles.

Using this line of code, you can tell which page to display which category of posts.

You can read more info about this at my blog if you need it: WordPress: How to control which category of posts displays on particular pages

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top