• Resolved nadyaQL

    (@nadyaql)


    hi, i need to allow tags and a couple of taxonomies to the portfolio,
    what is the best way for it works fine with the portfolio and i don’t lose the changes if i update, thanks.

    note: i understand only the feature will be used as filter. but i will like to have this another taxonomies so i can display them on each page.

    im not sure if i explain this right. my english still need to improve.

    thanks!

    https://wordpress.org/plugins/arconix-portfolio/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author John Gardner

    (@jgardner03)

    I’m sorry, I’m not certain I understand what you’re looking to do. Are you trying to add additional taxonomies to my plugin and then display them on the portfolio page?

    Thread Starter nadyaQL

    (@nadyaql)

    i want to add additional taxonomies to portfolio post type,
    this taxonomies will display at the single page of each portfolio item.

    Additional i need to add a tag .

    Plugin Author John Gardner

    (@jgardner03)

    You need to add 1 or more additional taxonomies, as well as support for the built-in post tags, yes?

    Thread Starter nadyaQL

    (@nadyaql)

    yes! 🙂
    thank you!

    Plugin Author John Gardner

    (@jgardner03)

    No problem.

    The only thing which could cause an issue with my plugin is adding post_tag support since that would require editing plugin code. I have a filter in place specifically so you can make changes to my plugin without having to edit code. Follow the code below:

    https://gist.github.com/j-gardner/10928035

    As far as registering your additional taxonomies, those wouldn’t affect my plugin at all. Simply register your taxonomy and use portfolio as the second argument in the register_taxonomy() function.

    The for the single page, edit the template and use get_the_term_list() for each additional taxonomy you’re adding to the portfolio post type.

    Does that make sense?

    Thread Starter nadyaQL

    (@nadyaql)

    thanks!
    im going to do it now.

    Thread Starter nadyaQL

    (@nadyaql)

    hello John,
    i got the tags working fine, im wondering if i can have a column for the tags at the admin panel?

    and also wondering if is posible to add categories to the portfolio. if this is posible can i have a column for the categories at the admin panel?

    thank you !

    Plugin Author John Gardner

    (@jgardner03)

    Excellent.

    The same function that added the post tag can simply be modified like so to add category support:

    $defaults['post_type']['args']['taxonomies'] = array( 'post_tag', 'category' );

    I never considered admin column customization when I was originally coding my plugin, and admin columns are one of the few areas in which I didn’t place any filters for easier customization by users. I’m currently in the process of making some significant structural improvements to the plugin, and addressing this is on my list.

    If you wanted to try to do it anyway, you would have to add a function (wherever you put the code to add post_tag support would be a suitable location) that would redefine all the columns while adding tags and categories columns as well. Then you’d have to hook on and provide the values for those columns as well.

    For the column definition part:

    add_filter( 'manage_portfolio_posts_columns', 'custom_portfolio_admin_columns', 11 );
    
    function custom_portfolio_admin_columns( $columns ) {
            $columns = array(
                'cb' => '<input type="checkbox" />',
                'portfolio_thumbnail' => __( 'Image', 'acp' ),
                'title' => __( 'Title', 'acp' ),
                'portfolio_description' => __( 'Description', 'acp' ),
                'portfolio_features' => __( 'Features', 'acp' ),
                'portfolio_link' => __( 'Link Type', 'acp' ),
                'tags' => __( 'Tags', 'acp' ),
                'categories' => __( 'Categories', 'acp' ),
                'date' => __( 'Date', 'acp' )
            );
    
            return $columns;
    }

    For the values:

    add_action( 'manage_posts_custom_column', 'custom_column_values', 11 );
    
    function columns_data( $column ) {
            global $post;
            if( 'portfolio' != get_post_type() ) return;
    
            switch( $column ) {
                case 'tags' :
                    echo get_the_term_list( $post->ID, 'post_tag', '', ', ', '' );
                    break;
                case 'categories':
                    echo get_the_term_list( $post->ID, 'category', '', ', ', '' );
                    break;
            }
        }

    I haven’t tested any of that code, but it should be fairly close.

    Alternatively you avoid all of that and when I release 1.4.0 the columns will show up automatically for builtin and any custom taxonomies (as long as the custom taxonomies has 'show_admin_column' => true, set for registration).

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘tag and taxonomy’ is closed to new replies.