Closed danyj closed 8 years ago
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 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
@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 ?
@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())
Please test.
@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>';
Do you know how to fix that and create a pull request?
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
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
Thank you
if you decide and find time to add it , dont go nuts , just redirect the view to portfolio archive
@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 ,
yeah that is not right , even some menu assignments dont play well,
yes , they should be separated , even woocommerce has product-tag and the view redirects to woo archive displaying products with that tag
Is there any way that you can add tags to portfolio extension ?