Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Let me explain.

I have a link www.mydomain.com/%artist-name%/%song-title%/.
artist-name is a custom post type.
song-title is the title of the post.

Now, www.mydomain.com/%artist-name%/%song-title%/ displays the song entry -which is working great.

The problem is when I'm in www.mydomain.com/%artist-name%/. It would display all the post titles. I don't want it to be that. Is there a way to make it post the artist's info?

note:

%artist-name% and %song-title% can have any value. That's why it's really a problem.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You can create specific single.php for your custom post types, in the form single-customposttype.php (it's the same with archive.php, see Template Hierarchy) for example single-artist-name.php. Then in those templates you can do pretty much whatever you want.

UPDATE

Here's a very simple example of single-artist-name.php :

<?php get_header(); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <div id="content">
        <h2>Artist : <?php the_title(); ?></h2>
        <?php the_content(); ?>
    </div>
<?php endwhile; ?>
<?php get_footer(); ?>

With this, if you visit www.mydomain.com/miles-davis/ you'll see for example :

Artist : Miles Davis

Widely considered one of the most influential musicians of the 20th century etc.

And so on, the same single post template would be applied to any artist-name post.

What sounds strange to me is why would you see all post titles when you visit www.mydomain.com/%artist-name%/, that looks more like a taxonomy archive. Are you sure that artist-name is registered as a custom post type?

share|improve this answer
    
sounds cool but is there any simpler than that? because I don't want to create all the artist's name, like single-michael-jackson.php... hmmm.. –  Reigel Jun 9 '11 at 4:04
1  
No need for repetition, you create only one single-artist-name.php, if artist-name is how your custom post type is called (as you say in your question) and WP is going to apply this template to all posts of this type. –  mike23 Jun 9 '11 at 4:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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