So i have 2 post types 'loads' and 'invoices'. Invoices is also used to show loads posts. I need not Invoices posts at all.
What I have Done: I used this code to show loads posts on Invoice page.
add_action( 'pre_get_posts', 'join_cpt_list_wspe_113808' ); function join_cpt_list_wspe_113808( $query ) { // If not backend, bail out if( !is_admin() ) return $query; // Detect current page and list of CPTs to be shown in Dashboard > invoice > Edit screen global $pagenow; $cpts = array( 'loads' ); if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'invoices' == get_query_var('post_type') ) ){ //set post type $query->set( 'post_type', $cpts ); //Get original meta query $meta_query = (array)$query->get('meta_query'); // show loads that are sent to invoice $meta_query[] = array( 'key' => 'load_status', 'value' => 'complete', 'compare' => '=', ); // Set the meta query to the complete, altered query $query->set('meta_query',$meta_query); } return $query; }
What I want:
On Invoice listing page, column values are not being shown. See screenshot:
I am trying this code to get values:
function invoice_columns ( $columns ) { //unset($columns['title']); unset($columns['date']); return array_merge ( $columns, array ( 'company' => __ ( 'Company' ), 'invoice' => __ ( 'Invoice #' ) , 'reference' => __ ( 'Reference' ) , 'delivery_date' => __ ( 'Delivery Date' ) , 'sent_on' => __ ( 'Sent On' ) , 'invoice_date' => __ ( 'Invoice Date' ) , 'due_date' => __ ( 'Due Date' ) , 'invoice_total' => __ ( 'Invoice Total' ) , 'balance' => __ ( 'Balance' ) ) ); } add_filter ( 'manage_invoices_posts_columns', 'invoice_columns' ); function invoice_custom_column($column, $post_id){ echo $column; echo $post_id; } add_action ( 'manage_invoices_posts_custom_column', 'invoice_custom_column', 10, 2 );
Please give your solutions.
invoices
, and then used your exact code, and it worked (cln.sh/kHwPTYb0). Have you tried your code on a fresh WordPress install?