I'm using a theme that uses a custom post type called Albums to create an archive of (strangely) albums consisting of a media player and brief bio. What I need however, is to be able to either duplicate the post type and call the second one Singles or to add a category option to both the Post page and the archive.

I've asked the theme developer and they won't help. I'm at a dead end.

I can provide pages if necessary.

Many Thank Yous



Assuming that your post type is registered as albums, you can add a custom taxonomy to the post type as follows:

add_action( 'init', 'create_album_taxonomy' );

function create_album_taxonomy() {
        'albums', // content type here
            'label' => __( 'Album Type' ),
            'rewrite' => array( 'slug' => 'albumtype' ),
            'hierarchical' => true,

Place this in your functions.php. Hope this helps

| improve this answer | |
  • Sadky, this has made no difference to either the Archive page or the Post editor. Thanks though Svaarband – Andy Woggle Feb 28 '17 at 11:54
  • Pleasure, this should work in adding categories (taxonomy) to the custom post. You would just need to modify the archive etc. but I take it that you don't have a lot of development experience? – Svartbaard Feb 28 '17 at 11:57
  • I can understand and follow, but this is a bit beyond me off the top of my head.. Thanks for help! – Andy Woggle Feb 28 '17 at 12:06

I think you have to add the taxonomies parameter in the register_post_type() function for that particular custom post type. Below is an example snippet:

register_post_type( 'albums', array(
  'taxonomies'          => array( 'category' ),
) );

Take a look yourself, hope this was helpful for you.

Reference: https://codex.wordpress.org/Function_Reference/register_post_type

| improve this answer | |

I've read through the codex a couple of times and I'm really not following. Here's the Post-Type code, it doesn't seem to follow

<div id="post-<?php the_ID(); ?>" <?php post_class('media-block'); ?>>
<?php if(get_field('alb_link_external')): ?>
<a target="_blank" href="<?php echo get_field('alb_link_external'); ?>">
<?php else: ?>
<a href="<?php the_permalink(); ?>">
<?php endif; ?>
    <div class="holder">
        <div class="image"><?php the_post_thumbnail( array(216,216) ); ?></div>
        <div class="text-box">
            <i class="media-decoration media-audio fa fa-headphones"></i>
            <h2><?php the_title(); ?></h2>
            <?php if(get_field('alb_release_date') != '') : ?>
            <time class="datetime" datetime="<?php echo date( 'c', strtotime( get_field('alb_release_date') ) ); ?>"><?php echo __("Release date", IRON_TEXT_DOMAIN); ?> <?php the_field('alb_release_date'); ?></time>
            <?php endif; ?>

| improve this answer | |

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.