Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress : Add a custom field directly above the title input field (w/o modifiying core files)?

Does anyone know of a way to add an input field (or any type of html for the matter) directly above (or below) the title input field on the post edit page ?

I'm looking of a way to do this without modifying core files (I'm doing this as part of a plug-in which creates a custom post-type).

I'm not aware of any available wp hooks in that area of the edit-form-advanced.php file which could help out. I really hope some has come up with a genius workaround !

like image 390
sctgraham Avatar asked Dec 29 '22 08:12

sctgraham


1 Answers

Since version 3.5 wordpress introduced new hooks for the add/edit post screen called edit_form_after_title and edit_form_after_editor. So now i think we can easily add new html element after wordpress input title and input content.

just use filter like this on your functions.php

add_action( 'edit_form_after_title', 'my_new_elem_after_title' );
function my_new_elem_after_title() {
    echo '<h2>Your new element after title</h2>';
}

add_action( 'edit_form_after_editor', 'my_new_elem_after_editor' );
function my_new_elem_after_editor() {
    echo '<h2>Your new element after content</h2>';
}
like image 52
Lafif Astahdziq Avatar answered Jan 05 '23 15:01

Lafif Astahdziq