Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Custom post type hierarchy

Featured Replies

Hey,

 

Ive got a website that uses custom post types to display album covers as links. I want to be click on the particular album cover and then go to a page that shows the titles of the songs in that particular album as links to a page where that particular songs lyrics are.

 

I have got so far as to display the album covers with custom fields and that works well, but when you click on the link, it goes to single.php. What i really want is for it to go into another page or custom index page.

 

How would I achieve this? Would i have to create a custom post type with in another, or should i look at custom taxonomies?

 

Atm the custom posts are being displayed on a custom page.

 

Many thanks

You need to create a file called single-album.php (assuming your CPT is called album). There you would create a template specific to your album page.

Edited by mantis

  • Author

Thanks for the reply,

 

Ive tried this and it works well and has got me closer to where I need to be, but Im still not quite there. Is it still ok to use a single.php file in wp as an index.php 'like' page?

 

Is there a way to not use a single.php file? I think that using a template file like that will limit what i what i want to out put on it which is essentially more posts with permalinks into more posts.

It sounds like massive overkill to me to be using custom post types to display album covers? You could achieve the exact same just using Featured Images with normal posts or pages. With pages it's then very easy to arrange hierarchical relationships, and I believe you can do the same with posts.

 

I did find this though: http://janina.tumblr.com/post/3588081423/post-parent-different-type

Wordpress follows a template hierarchy starting with index.php.

 

In order to override the default you need to specify a template either by naming it correctly (see image) or by creating a custom template that can be applied to a page.

post-30522-0-41315200-1349871795_thumb.png

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.