function wpdocs_register_meta_boxes() { add_meta_box( ‘meta-box-id’, __( ‘Backend Name’, ‘textdomain’ ), ‘wpdocs_my_display_callback’, ‘post_type’ ); } add_action( ‘add_meta_boxes’, ‘wpdocs_register_meta_boxes’ ); function wpdocs_my_display_callback( $post ) { // INPUT FIELDS GO HERE ?> <label>Year: <input type=”text” name=”inputName” value=”<?php echo get_post_meta(get_the_ID(), ‘meta_key’)[0]; ?>” /></label> <?php } /** * Save meta box content. * * @param int $post_id Post ID */ […]
Category Archives: Custom posts
add_action( ‘manage_colourmedia_column’, ‘colourmedia_columns’, 10, 2 ); function manage_colourmedia_columns( $column, $post_id ) { global $post; $terms = get_post_meta( $post_id ); switch( $column ) { case ‘thumbnail’ : $url = get_the_post_thumbnail_url($post_id); printf( ‘<img src=”‘.$url.'” style=”width:100px”/>’ ); break; case ‘city’ : printf($terms[‘City’][0]); break; case ‘category’ : $cat_list = wp_get_post_terms($post->ID, ‘category’, array(“fields” => “names”)); foreach($cat_list as &$category){ echo ‘<a […]
function reg_cat() { register_taxonomy_for_object_type(‘category’,’scr’); } add_action(‘init’, ‘reg_cat’);
add_filter( ‘manage_edit-colourmedia_columns’, ‘colourmedia_columns’ ) ; // init function function colourmedia_columns( $columns ) { $columns = array( ‘cb’ => ‘<input type=”checkbox” />’, ‘thumbnail’ => __( ‘Thumbnail’ ), ‘category’ => __( ‘Category’ ), ‘title’ => __( ‘Name’ ), ‘city’ => __( ‘City’ ), ‘featured’ => __( ‘Featured’ ), ); return $columns; }
function colourmedia_post_type() { $args = array( ‘public’ => true, ‘label’ => __( ‘BackendName’, ‘textdomain’ ), ‘supports’ => array( ‘title’, ‘editor’, ‘author’, ‘thumbnail’, ‘excerpt’, ‘comments’, ‘custom-fields’ ), ‘menu_icon’ => ‘dashicons-megaphone’, ); register_post_type( ‘colourmedia’, $args ); } add_action( ‘init’, ‘colourmedia_post_type’ );