Tags for custom post type

  • Stephen
    Stephen
    Senior Member 215 points
    August 17, 2013 at 12:02 am

    I haven’t been able to figure this out in CP 4.2 – I want to add tags to the coupon posts. Is this possible without a lot of work?

  • Aaron
    Aaron
    Super Guru 920 points
    August 17, 2013 at 3:28 am

    Tags for the default post type are just Taxonomies.

    You could use Marks Taxonomy plugin to add them or put this in your themes _functions.php

    // NEW TAXONOMIES
    register_taxonomy( ‘tag’, THEME_TAXONOMY.’_type’, array( ‘hierarchical’ => true, ‘labels’ => array(‘name’ => ‘Tags’) , ‘query_var’ => true, ‘rewrite’ => true ) );

  • Stephen
    Stephen
    Senior Member 215 points
    August 17, 2013 at 5:11 pm

    Hmmmm did not know there was a new plugin.

    Thanks Aaron

  • Ezenwa
    Ezenwa
    Newbie 1 points
    August 22, 2013 at 5:17 am

    You can do it without plugin, try to add reg tag code below to the function.php

    function reg_tag() {
    register_taxonomy_for_object_type('post_tag', 'post_type_name');
    }
    add_action('init', 'reg_tag');
    add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );

    change the “post_type_name” to your registered post type

  • Mark Fail
    Mark Fail
    Super Guru 13,013 points
    August 22, 2013 at 10:56 am

    thanks for sharing

Viewing 5 posts - 1 through 5 (of 5 total)

New Business Themes for WordPress 2020

Start your new website today!

View Business Themes