• Resolved danielgc

    (@danielgc)


    Hello. I’m using the free version. Having many posts is kind of confusing, and I see that you have added interface_itme_data filter “to append additional data for items within sortable interface”… how can I use it to show not only the title in the draggable box but the term for example (the title & term name) so it’d be easier to sort the posts?

    Any help would be highly appreciated!

    thx!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Maya

    (@tdgu)

    Hi,
    You can use this example which apply for advanced version, but change the filter name from ‘apto_reorder_item_additional_details’ to ‘cpto/interface_itme_data’

    https://www.nsp-code.com/advanced-post-types-order-api/filter-post-types-items-additional-informations/

    Thanks

    Thread Starter danielgc

    (@danielgc)

    Thx tdgu, I tried with this after watching your link:

    add_filter('apto_reorder_item_additional_details', 'theme_apto_reorder_item_additional_details', 10, 2); 
    function  theme_apto_reorder_item_additional_details($additional_details, $post_data)
    {
        
        $terms = get_the_terms( $post_data->ID, 'categoria_general' );
        $value = $terms[0]['name'];
        $additional_details .= $value;
        
        return $additional_details;
    }

    But it didn’t work ?? I’m sure that’s the name of my taxonomy.

    As @tdgu said, you need to rename the filter so your first line should actually be:

    add_filter('cpto/interface_itme_data', 'theme_apto_reorder_item_additional_details', 10, 2);

    This will only show extra data on the “re-order” page.

    You should also write some custom columns code to surface this information in your main post indexes. Check out this https://code.tutsplus.com/articles/add-a-custom-column-in-posts-and-custom-post-types-admin-screen–wp-24934.

    Here is a complete example of both techniques that I used on a project I’m currently working on:

    
    // Add custom field to Exhibitor CPT index "FEATURED"
    // https://code.tutsplus.com/articles/add-a-custom-column-in-posts-and-custom-post-types-admin-screen--wp-24934
    function rtp_columns_head_only_exhibitor($defaults) {
        $defaults['is_featured'] = __('Featured Exhibitor?');
        return $defaults;
    }
    function rtp_columns_content_only_exhibitor($column_name, $post_ID) {
        if ($column_name == 'is_featured') {
            $is_featured = get_field('is_featured', $post_ID);
            if($is_featured) {
              echo '<span style="background-color: #D54E21; color: #fff; padding: 3px 5px; text-transform: uppercase;">' . __("Featured") . '</span>';
            } else {
              echo '<span style="background-color: #ddd; padding: 3px 5px; text-transform: uppercase;">' . __("Not Featured") . '</span>';
            }
        }
    }
    add_filter('manage_exhibitor_posts_columns', 'rtp_columns_head_only_exhibitor', 10);
    add_action('manage_exhibitor_posts_custom_column', 'rtp_columns_content_only_exhibitor', 10, 2);
    
    // Add custom notation to Reorder page by Post Types Order plugin
    function rtp_show_isfeatured_on_posttypesorder_page($item_details, $page) {
      if("exhibitor" == $page->post_type) {
        $is_featured = get_field('is_featured', $page->ID);
    
        $is_featured_snippet = '<span style="margin-right: 10px; background-color: #D54E21; color: #fff; padding: 3px 5px; text-transform: uppercase; display: inline;">' . __("Featured") . '</span>';
    
        if($is_featured){
          $item_details = $is_featured_snippet . $item_details;
        }
      }
    
      return $item_details;
    }
    add_filter('cpto/interface_itme_data', 'rtp_show_isfeatured_on_posttypesorder_page', 10, 2);
    
    Thread Starter danielgc

    (@danielgc)

    wow, thx rtpHarry!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding taxonomy to the title in the admin’ is closed to new replies.