1

I'm trying to set up a portfolio page on my wordpress website, and I would like the following construct:

  • /blog/ where I blog all kinds of things, including portfolio entries
  • /portfolio/ where I show just posts from my portfolio category
  • some regular /pagename/ pages (about, contact, etc)

I want the portfolio section to have a separate style (and even html probably) than a regular category overview. So if someone clicks one of the categories in my blog they still see the normal /category/randomcategory/ overview page. This means I can't just change the category php page and/or the css, because the portfolio page is different from the regular view.

Is there a way to set up my page so that it shows the posts in the category portfolio the way I want?

  • Hmm, or should I use custom post types for this? I only just found out about those... – Stephan Muller Nov 18 '10 at 12:38
1

The page of posts example pulls posts from one category, it uses a custom field to designate the category, which in turn makes the page template re-usable on other pages with other categories to, if you so choose..

You can style that template however you like..

Hope that helps..

  • Finally had time to look at this, works like a charm. Thanks! – Stephan Muller Nov 22 '10 at 15:45
1

First, you will need to create custom page template. Refer to this page to see how to create it.

Second, on that page (you can copy from your page.php/index.php, the important part is:

if (have_posts()) : while (have_posts()) : the_post();

Find that piece and add this code just right above that code:

query_posts('cat=3&paged='.get_query_var( 'paged' ));

Things to note from above query_posts snippet is:

Hope that helped.

  • Thanks, this looks good. I'm going to explore custom post types first, but if that doesn't work I'm going to use this :) Thanks everyone else for the answers as well! – Stephan Muller Nov 18 '10 at 12:48
  • This is all covered on the Codex entry i linked to in my answer, and you don't even need to know the category ID following the codex example. – t31os Nov 18 '10 at 12:49
1

take a look at http://codex.wordpress.org/Template_Hierarchy . You can see in the category template section that you can use either category-10.php or category-portfolio.php (in case your portfolio category id is 10 and the slug is "portfolio") to override the default archive.php file.

This way, you can customize the HTML/CSS in the new file you create and it will have an effect only on the portfolio template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.