Posted By : Date : fanuzzi | 04-03-2021
To edit the Admin header of your new post type page you need to add the following code: Hook add_action(‘admin_head-edit.php‘,’edit_change_title_function’); The edit function in your function you have to check if the post type is the one you need, and then apply a filter for the title function edit_change_title_function(){ global$post; if($post->post_type == 'posttype_name') { add_filter('the_title','posttype_title_function',100,2); } } So, you can override the title getting the value from db: function posttype_title_function($title, $post_id) { $new_title = get_post_meta($post_id,'slb_first_name',true) .' '.get_post_meta($post_id,'slb_last_name',true); return $new_title; }
Read More
0 Comments
Posted By : Date : fanuzzi | 04-03-2021
A custom fields are, basically, the properties for a post type. The creation phase of a custom field is divided in two parts: Creation of the structure Define the behavior Creation of the structure Add metabox Metabox is the graphic container of our custom fields. It will appear as a fieldsets in the admin page, containing our custom fields. add_action('add_meta_boxes_{post_type_name}','add_metabox_function');function add_metabox_function($post){  add_meta_box('id','title','metabox_field_function','post_type_name','normal','default');} This function will contain all necessary html, CSS and logical code to manage and show our custom fields. function metabox_field_function(){   //html code to show fields and php…
Read More
0 Comments
WordPress Custom Post Type
Posted By : Date : fanuzzi | 04-02-2021
Post types are a way to categorize different types of content in WordPress. Wordpress has already the following native post type: Post Pages Attachments Revisions Navigation menu custom CSS Changeset Most probably you just knew about the first three in the list. And you can extend these wordpress post type with your own. To do this you here it is a little function recap. Hook custom post type definition Hook add_action( 'init', 'custom_posttype_def', 0 ); custom post type definition function custom_posttype_def() { // Set UI labels for Custom Post Type…
Read More
0 Comments
Posted By : Date : fanuzzi | 04-02-2021
Here it is a little schema to recap the creation of a wp shortcode 1. Hook 2. Shortcode registration 3. Shortcode content 1. Hook add_action('init','callback_register_shortcode'); 2. Shortcode registration function callback_register_shortcode(){ add_shortcode('shortcode_name','sc_content_function');}   3. Shortcode content function sc_content_function($args, $content=""){   $output="<div> shortcode html content</div>";   echo $output;} But how we can submit data through shortcodes? Here it is. Hook you need to register two ajax function: add_action('wp_ajax_nopriv_{save_your_posttype_function}', 'save_your_posttype_function'); // regular website visitoradd_action('wp_ajax_{save_your_posttype_function}', 'save_your_posttype_function'); // admin user submit action The submit action inside your shortcode must be something like this: action="/wp-admin/admin-ajax.php?action=save_your_posttype_function" method="post"…
Read More
0 Comments