Okay
  Public Ticket #1981914
Portfolio tags
Closed

Comments

  •  1
    flowerz started the conversation

    Hi there, I am just wondering if there is a way to add tags to a portfolio item. I am trying to build a portfolio with filters based on the tags rather than just the categories. Is there a way to do that? Thank you very much. 

  • aguiareric replied

    I'm with the same problem

  •  675
    Neuron replied

    Hi Guys,

    I will explain the process below, how that can be done.

    1) I would recommend to add the following snippet in the functions.php of the child theme. This will create the tags as taxonomy and assign it to the portfolio post type.

    /**
     * Portfolio Tags
     */
    function neuron_portfolio_tags() {     $labels = array(
            'name'                       => __('Portfolio Tags', 'neuron-core'),
            'singular_name'              => __('Portfolio Tag', 'neuron-core'),
            'menu_name'                  => __('Portfolio Tags', 'neuron-core'),
            'edit_item'                  => __('Edit Portfolio Tag', 'neuron-core'),
            'update_item'                => __('Update Portfolio Tag', 'neuron-core'),
            'add_new_item'               => __('Add New Portfolio Tag', 'neuron-core'),
            'new_item_name'              => __('New Portfolio Tag Name', 'neuron-core'),
            'parent_item'                => __('Parent Portfolio Tag', 'neuron-core'),
            'parent_item_colon'          => __('Parent Portfolio Tag:', 'neuron-core'),
            'all_items'                  => __('All Portfolio Tags', 'neuron-core'),
            'search_items'               => __('Search Portfolio Tags', 'neuron-core'),
            'popular_items'              => __('Popular Portfolio Tags', 'neuron-core'),
            'separate_items_with_commas' => __('Separate portfolio tags with commas', 'neuron-core'),
            'add_or_remove_items'        => __('Add or remove portfolio tags', 'neuron-core'),
            'choose_from_most_used'      => __('Choose from the most used portfolio tags', 'neuron-core'),
            'not_found'                  => __('No portfolio tags found.', 'neuron-core'),
            'items_list_navigation'      => __('Portfolio tags list navigation', 'neuron-core'),
            'items_list'                 => __('Portfolio tags list', 'neuron-core'),
        );     $args = array(
            'labels'            => $labels,
            'public'            => true,
            'show_in_nav_menus' => true,
            'show_ui'           => true,
            'show_tagcloud'     => true,
            'hierarchical'      => true,
            'rewrite'           => array('slug' => 'portfolio_tags'),
            'show_admin_column' => true,
            'query_var'         => true,
        );     register_taxonomy('portfolio_tags', 'portfolio', $args);
    } /**
     * Add Tags to Portfolio
     */
    function neuron_custom_portfolio_tags() {
    neuron_portfolio_tags();
    }
    add_action('init', 'neuron_custom_portfolio_tags');

    2) The next changes needs to be done directly on the plugin(Neuron Core).

    Open filters.php which is located in neuron-core > widgets > posts > templates > filters.php and add the following snippet. http://prntscr.com/neho8f

    /**
     * Override
     */
    if ($settings['posts_type'] == 'portfolio') {
        $neuron_posts_taxonomy = 'portfolio_tags';     $post_terms = get_terms('portfolio_tags');
        if ($post_terms && !is_wp_error($post_terms)) {
            foreach ($post_terms as $term) {
                $post_categories[$term->slug] = $term->name;    
            }
        }     $neuron_posts_normal_query = $post_categories;
    }

    In the file layout-isotope.php  which is located at neuron-core > widgets > posts > layout > layout-isotope.php in the line 137 replace $neuron_posts_taxonomy with 'portfolio_tags'

    - http://prntscr.com/nehojm 

    I have tested this on my localhost, everything worked alright, do not forget to flush the permalinks(click save changes on the Settings > Permalinks).

    Feel free to ask for anything you need :)

    Kind Regards,
    NeuronThemes


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.