Jump to content

custom post types troubles


epicnic

Recommended Posts

I watched the custom post types (thanks Ben for the nice work) videos and had an idea for my own blog.

 

I sometimes get asked to write a review on my blog about music, games, books, ...

When I do such a review it's just a normal blogpost among the others. I had the idea to create 3 custom post types: muziek (music), boeken (books), games. I want to use the custom post types to get a nice overview of everything I reviewed in a certain category (post-type). I want http://epicnic.be/?post_type=muziek to show a overview like in the videos of Ben where It shows just a picture and a rating of the reviewed product (in this case the music).

 

Now I know i can do this by using an if statement which checks if get_post_type == muziek and tweeking the css to align everything in a grid.

 

Now my prolbem is that if I include the music post types posts in my normal blog It should still display them like a normal blogpost.

 

Is there maybe a function I can include in my if statement that could solve my problem?

 

Note: I didn't use custom taxonomy because my post-types itself are the only "taxonomy" I need.

 

Edit: I tried to use the is_home() and the is_front_page() function but when I do this on http://epicnic.be/?post_type=muziek it also returns value "1"

Link to comment
Share on other sites

I would probably handle this by creating a page template with a custom query. This would probably be helpful http://www.wpbeginner.com/wp-tutorials/how-to-create-a-custom-post-types-archive-page-in-wordpress/ and this section (bottom of the page) talks about custom queries: http://codex.wordpress.org/Custom_Post_Type

 

To be honest, there are still things about custom post types that confuse me a bit, so there may be a "better" way to do this that I don't know about yet.

Link to comment
Share on other sites

The link about custom post archives is probably the solution I seek.

 

It's a bit strange that wordpress can show site.com/movies/walktheline as a one-custom-post-page but when you try site.com/movies/ you get nothing as logic as an archive of all your custom posts.

 

Thanks for the links I'll try this one out later this week and let you know if it worked.

Link to comment
Share on other sites

It's a bit strange that wordpress can show site.com/movies/walktheline as a one-custom-post-page but when you try site.com/movies/ you get nothing as logic as an archive of all your custom posts.

Agreed. I thought that was something that was coming in WP3.1, and I thought that based on comments I had read in the WP bugtracker that it had been put in place, but I can't track the link down and I haven't had time to experiment with it yet.

 

Definitely check out the plugin I linked to -- it may save you a significant amount of time rather than writing everything yourself.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...