Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

[feature] Portfolio extension tags

Open danyj opened this issue 10 years ago • 14 comments

Is there any way that you can add tags to portfolio extension ?

danyj avatar Dec 25 '15 16:12 danyj

Add this

$labels = array(
            'name' => __('Tags','fw' ),
            'singular_name' => __('Tag', 'fw'),
            'search_items' => __('Search Tags','fw'),
            'popular_items' => __( 'Popular Tags','fw' ),
            'all_items' => __('All Tags','fw'),
            'parent_item' => null,
            'parent_item_colon' => null,
            'edit_item' => __('Edit Tag','fw'),
            'update_item' => __('Update Tag','fw'),
            'add_new_item' => __('Add New Tag','fw'),
            'new_item_name' => __('New Tag Name','fw'),
            'separate_items_with_commas' => __( 'Separate tags with commas','fw' ),
            'add_or_remove_items' => __( 'Add or remove tags','fw' ),
            'choose_from_most_used' => __( 'Choose from the most used tags','fw' ),
        );

        register_taxonomy('tags', 'fw-portfolio', array(
            'hierarchical' => false,
            'labels' => $labels,
            'public' => true,
            'show_ui' => true,
            'update_count_callback' => '_update_post_term_count',
            'query_var' => true,
            'rewrite' => array('slug' => 'portfolio-tag')
        ));

on init action

add_action( 'init', 'function_name');

puyaalexxx avatar Dec 30 '15 13:12 puyaalexxx

@puyaalexxx thnx for the reply I did not see it at all , but we cant do this from theme otherwise it wont pass TF theme check , this needs to be done on plugin level

http://prntscr.com/9sorc7

danyj avatar Jan 20 '16 21:01 danyj

@moldcraft I see you monitor this, I need to code the portfolio page , is it ok for me to add this

function _action_fw_ext_portfolio_tags( ) {

    $labels = array(
        'name' => __('Tags','fw' ),
        'singular_name' => __('Tag', 'fw'),
        'search_items' => __('Search Tags','fw'),
        'popular_items' => __( 'Popular Tags','fw' ),
        'all_items' => __('All Tags','fw'),
        'parent_item' => null,
        'parent_item_colon' => null,
        'edit_item' => __('Edit Tag','fw'),
        'update_item' => __('Update Tag','fw'),
        'add_new_item' => __('Add New Tag','fw'),
        'new_item_name' => __('New Tag Name','fw'),
        'separate_items_with_commas' => __( 'Separate tags with commas','fw' ),
        'add_or_remove_items' => __( 'Add or remove tags','fw' ),
        'choose_from_most_used' => __( 'Choose from the most used tags','fw' ),
    );

    register_taxonomy('tags', 'fw-portfolio', array(
        'hierarchical' => false,
        'labels' => $labels,
        'public' => true,
        'show_ui' => true,
        'update_count_callback' => '_update_post_term_count',
        'query_var' => true,
        'rewrite' => array('slug' => 'portfolio-tag')
    )); 

}

add_action( 'init', '_action_fw_ext_portfolio_tags');

after this filter https://github.com/ThemeFuse/Unyson-Portfolio-Extension/blob/master/hooks.php#L64

until you add it to the extension ?

danyj avatar Feb 02 '16 15:02 danyj

@moldcraft this snipp wont work , there are no tags in the $post tags are in backend http://prntscr.com/9y3fbw

but this is empty

wp_get_post_tags(get_the_ID())

danyj avatar Feb 02 '16 15:02 danyj

Please test.

ghost avatar May 13 '16 13:05 ghost

@moldcraft the filter works , thnx!

but we have no tag view and the links cant find the tagged projects

$tags = wp_get_post_tags($post->ID); 
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );

$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
$html .= "{$tag->name}</a> ";
}
$html .= '</div>';

danyj avatar May 13 '16 13:05 danyj

Do you know how to fix that and create a pull request?

ghost avatar May 13 '16 14:05 ghost

Honestly no idea , I never dealt with it. So far I see from all other themes portfolios there needs to be custom tax for tags http://prntscr.com/b3kxzw and we cant use the wp default which is what we just did , thus the link is tryng to find blog posts with the tags and not projects

danyj avatar May 13 '16 14:05 danyj

so we need tax

fw-porfolio-tag  

edit-tags.php?taxonomy=fw-portfolio-tag&post_type=fw-portfolio

just like we have

fw-portfolio-category

edit-tags.php?taxonomy=fw-portfolio-category&post_type=fw-portfolio

danyj avatar May 13 '16 14:05 danyj

Thank you

ghost avatar May 13 '16 14:05 ghost

if you decide and find time to add it , dont go nuts , just redirect the view to portfolio archive

danyj avatar May 13 '16 14:05 danyj

@moldcraft I am not sure if this will help you

but with this filter

add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
  if( is_tag() ) {
    $post_type = get_query_var('post_type');
    if($post_type){
        $post_type = $post_type;
    }else{
        $post_type = array('post','fw-portfolio','nav_menu_item');
    }
    $query->set('post_type',$post_type);
    return $query;
    }
}

I get the tag view but is posts tag view mixing projects and blog posts and I am not even sure if that query is 100% ok.

I think that these 2 ( blog posts, projects ) should not be mixed and each should have own tag view ,

danyj avatar May 13 '16 21:05 danyj

yeah that is not right , even some menu assignments dont play well,

danyj avatar May 13 '16 21:05 danyj

yes , they should be separated , even woocommerce has product-tag and the view redirects to woo archive displaying products with that tag

danyj avatar May 13 '16 21:05 danyj