php Agregar专栏是一个非CPT o POST
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Agregar专栏是一个非CPT o POST相关的知识,希望对你有一定的参考价值。
<?php
// show column
function bw_columns_head($defaults) {
$defaults['number'] = 'Number';
return $defaults;
}
function bw_columns_content($column_name, $post_ID) {
if ($column_name == 'number') {
echo get_field('number', $post_ID);
}
}
// manage_services_posts_columns = manage_%CPT slug%_posts_columns
add_filter('manage_services_posts_columns', 'bw_columns_head');
add_action('manage_services_posts_custom_column', 'bw_columns_content', 10, 2);
// sort by meta number
add_action( 'pre_get_posts', 'services_number_orderby' );
function services_number_orderby( $query ) {
if( ! is_admin() )
return;
$orderby = $query->get( 'orderby');
if( 'number' == $orderby ) {
$query->set('meta_key','number');
$query->set('orderby','meta_value_num');
}
}
// make column sortable
// edit-services = edit-%CPT-slug%
add_filter( 'manage_edit-services_sortable_columns', 'sortable_service_number' );
function sortable_service_number( $columns ) {
$columns['number'] = 'number';
return $columns;
}
// si queremos agregar un filtro
// https://wordpress.stackexchange.com/questions/212519/filter-by-custom-field-in-custom-post-type-on-admin-page
以上是关于php Agregar专栏是一个非CPT o POST的主要内容,如果未能解决你的问题,请参考以下文章
PHP Php - Agregar href en textos
php Agregar项目菜单前端
php agregar自定义菜单
php Agregar columna en posttype
PHP Agregar Archivos是一款非常有用的产品
php Agregar Tabs personalizados en WooCommerce sin plugins