Wordpress: add custom field directly above header input field (without modifying kernel files)?

Does anyone know how to add an input field (or any html type for this question) directly above (or below) the header input field on the edit page after posting?

I am looking for a way to do this without changing the core files (I do this as part of a plug-in that creates a custom post-type).

I do not know about the available wp hooks available in this area of ​​the edit-form-advanced.php file that could help. I really hope that some come up with a brilliant solution!

+3
source share
2 answers

; add_action ('admin_head'). , , JavaScript + jQuery ( WP). , :

add_action('admin_head', 'my_admin_head_in_posts');
function my_admin_head_in_posts() {
?>
jQuery('#post').before(
'<div id="id_my_field" class="updated below-h2">' +
'<input type="text" name="my_field" value="lol" />' + 
'</div>'
);
<?php
}

- : alt text

+2

3.5 wordpress / , edit_form_after_title edit_form_after_editor. , , html Wordpress .

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>';
}
+1

Source: https://habr.com/ru/post/1762900/


All Articles