Zeigen Sie in der Rasteransicht von WordPress benutzerdefinierte Post Type-Werte an

Ich habe einen benutzerdefinierten Post-Typ in WordPress erstellt, wie in Abbildung gezeigt.

Bildbeschreibung hier eingeben Was ich möchte, ist die Werte in diesem benutzerdefinierten Beitrag in der Rasteransicht des Admin-Bereichs zu zeigen. Jetzt zeigt das Admin-Panel nur die Post-Titel-, Datums- und Kommentar-Bilder an, aber ich möchte die Pair2-, Buy-Sell- und Aktivitäts-Felder-Werte anzeigen, die in meinem benutzerdefinierten Post eingegeben wurden. Ich habe viel gesucht, konnte aber keine Lösung finden. Wie soll ich in WordPress vorgehen? Bildbeschreibung hier eingeben

BEARBEITEN
Hier ist, wie ich meine benutzerdefinierte Post mache

 __( 'ForexPair' ), 'singular_name' => __( 'ForexPair' ), 'add_new' => __( 'Add Pair Entry' ), 'all_items' => __( 'All Pairs' ), 'add_new_item' => __( 'Add Pair' ), 'edit_item' => __( 'Edit Pair' ), 'new_item' => __( 'New Pair' ), 'view_item' => __( 'View Pair' ), 'search_items' => __( 'Search Pairs' ), 'not_found' => __( 'No pair found' ), 'not_found_in_trash' => __( 'No pair found in trash' ), 'parent_item_colon' => __( 'Parent pair' ) //'menu_name' => default to 'name' ); $args = array( 'labels' => $labels, 'public' => true, 'has_archive' => true, 'publicly_queryable' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array( 'title' ), 'register_meta_box_cb' => 'quote_add_post_type_metabox' ); register_post_type( 'quote', $args ); //flush_rewrite_rules(); } add_action( 'init', 'quote_create_post_type' ); function quote_add_post_type_metabox() { // add the meta box //add_meta_box( 'quote_metabox', 'quote_metabox', 'quote', 'normal' ); add_meta_box( 'quote_metabox', 'Pair Entries', 'quote_metabox', 'quote', 'normal' ); } function quote_metabox() { global $post; // Noncename needed to verify where the data originated echo ''; // Get the data if its already been entered $quote_post_entryprice = get_post_meta($post->ID, '_quote_post_entryprice', true); $quote_post_stoploss = get_post_meta($post->ID, '_quote_post_stoploss', true); $quote_post_pairname = get_post_meta($post->ID, '_quote_post_pairname', true); $quote_post_buysell = get_post_meta($post->ID, '_quote_post_buysell', true); $quote_post_activity = get_post_meta($post->ID, '_quote_post_activity', true); $quote_post_takeprofit = get_post_meta($post->ID, '_quote_post_takeprofit', true); // Echo out the field ?>      .lbl{ width: 86px; display: block; line-height: 20px; }  

$(document).ready(function() { $("#e1").select2({ matcher: function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase())==0; } }); }); $(document).ready(function() { $("#e2").select2({ matcher: function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase())==0; } }); }); $(document).ready(function() { $("#e3").select2({ matcher: function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase())==0; } }); }); <option value="AUD/CAD" >AUD/CAD <option value="AUD/CHF" >AUD/CHF

ID; } // is the user allowed to edit the post or page? if( ! current_user_can( 'edit_post', $post->ID )){ return $post->ID; } $quote_post_meta['_quote_post_entryprice'] = $_POST['quote_post_entryprice']; $quote_post_meta['_quote_post_stoploss'] = $_POST['quote_post_stoploss']; $quote_post_meta['_quote_post_pairname'] = $_POST['quote_post_pairname']; $quote_post_meta['_quote_post_buysell'] = $_POST['quote_post_buysell']; $quote_post_meta['_quote_post_activity'] = $_POST['quote_post_activity']; $quote_post_meta['_quote_post_takeprofit'] = $_POST['quote_post_takeprofit']; // add values as custom fields foreach( $quote_post_meta as $key => $value ) { // cycle through the $quote_post_meta array // if( $post->post_type == 'revision' ) return; // don't store custom data twice $value = implode(',', (array)$value); // if $value is an array, make it a CSV (unlikely) if( get_post_meta( $post->ID, $key, FALSE ) ) { // if the custom field already has a value update_post_meta($post->ID, $key, $value); } else { // if the custom field doesn't have a value add_post_meta( $post->ID, $key, $value ); } if( !$value ) { // delete if blank delete_post_meta( $post->ID, $key ); } } } add_action( 'save_post', 'quote_post_save_meta', 1, 2 ); // save the custom fields endif; // end of function_exists() if( ! function_exists( 'view_quotes_posts' ) ) : // output function view_quotes_posts( $num = 4, $do_shortcode = 1, $strip_shortcodes = 0 ) { $args = array( 'numberposts' => $num, 'offset' => 0, //'category' => , 'orderby' => 'menu_order, post_date', // post_date, rand 'order' => 'DESC', 'post_type' => 'quote', 'post_status' => 'publish', 'suppress_filters' => true, ); $posts = get_posts( $args ); global $wpdb; $querystr = "select $wpdb->posts.* FROM $wpdb->posts WHERE $wpdb->posts.post_type = 'quote' "; $html = ''; foreach ( $posts as $post ) { $meta_entryprice = get_post_meta( $post->ID, '_quote_post_entryprice', true ); $meta_stoploss = get_post_meta( $post->ID, '_quote_post_stoploss', true ); $meta_pairname = get_post_meta( $post->ID, '_quote_post_pairname', true ); $meta_buysell = get_post_meta( $post->ID, '_quote_post_buysell', true ); $meta_activity = get_post_meta( $post->ID, '_quote_post_activity', true ); $meta_takeprofit = get_post_meta( $post->ID, '_quote_post_takeprofit', true ); $html.=''; $html .= ' '; $html.=''; } $html .="
PairActionStatusEntry PriceStop LossTake Profit
'.$meta_pairname.' '.$meta_buysell.' '.$meta_activity.' '.$meta_entryprice.' '.$meta_stoploss.' '.$meta_takeprofit.'
"; $html = '
'.$html.'
'; return $html; } endif; ?>

Solutions Collecting From Web of "Zeigen Sie in der Rasteransicht von WordPress benutzerdefinierte Post Type-Werte an"

Sie können den manage_edit-${post_type}_columns Verbindung mit der Aktion manage_${post_type}_posts_custom_column . Überprüfen Sie das Beispiel im Codex und dekonstruieren Sie es Schritt für Schritt.

Stellen Sie zuerst sicher, dass Sie den richtigen Namen Ihres registrierten benutzerdefinierten Post-Typs eingeben. Sie haben den Post-Typ mit dem Namen quote registriert.

Zweitens definieren Sie die Spalten, die Sie hinzufügen möchten (siehe set_custom_edit_quote_columns ) und ordnen Sie die entsprechenden Werte zu (siehe custom_quote_columns ).

Du solltest mit so etwas enden:

 add_filter( 'manage_edit-quote_columns', 'set_custom_edit_quote_columns' ); add_action( 'manage_quote_posts_custom_column' , 'custom_quote_columns', 10, 2 ); function set_custom_edit_quote_columns( $columns ) { $columns['pair'] = __( 'Pair' ); $columns['buysell'] = __( 'Buy Sell' ); $columns['activity'] = __( 'Activity' ); $columns['entryprice'] = __( 'Entry Price' ); $columns['stoploss'] = __( 'Stop Loss' ); $columns['takeprofit'] = __( 'Take Profit' ); return $columns; } function custom_quote_columns( $column, $post_id ) { switch ( $column ) { case 'pair' : echo get_post_meta( $post_id, '_quote_post_pairname', true ); break; case 'buysell' : echo get_post_meta( $post_id, '_quote_post_buysell', true ); break; case 'activity' : echo get_post_meta( $post_id, '_quote_post_activity', true ); break; case 'entryprice' : echo get_post_meta( $post_id, '_quote_post_entryprice', true ); break; case 'stoploss' : echo get_post_meta( $post_id, '_quote_post_stoploss', true ); break; case 'takeprofit' : echo get_post_meta( $post_id, '_quote_post_takeprofit', true ); break; } }