I want to show some information in post edit screen. I found 2 hooks which allow to do this after title or after editor. Heres code with second one:
add_action( 'edit_form_after_editor', 'myprefix_edit_form_after_editor' );
function myprefix_edit_form_after_editor() {
global $post;
$author_id=$post->post_author;
$email = get_the_author_meta( 'user_email', $author_id);
$imie = get_the_author_meta( 'first_name', $author_id);
$nazwisko = get_the_author_meta( 'last_name', $author_id);
$nip = get_the_author_meta( 'nip', $author_id);
$login = get_the_author_meta( 'user_login', $author_id);
$firma = get_the_author_meta( 'nazwa_firmy', $author_id);
echo '<h1>DANE FIRMY</h1>';
echo '<strong>Nazwa firmy: </strong>', $firma;
echo '<br><strong>ImiÄ: </strong>', $imie;
echo '<br><strong>Nazwisko: </strong>', $nazwisko;
echo '<br><strong>NIP: </strong>', $nip;
echo '<br><strong>E-mail: </strong>', $email;
echo '<br><strong>Login: </strong>', $login,'<br><br>';
}
I want this information to show only on post edit pages – now it shows everywhere (custom post type edit pages, pages edit screens etc.).
Maybe theres hook which allows to show this info under featured image (right part of edit screen).
Often with WP, it really helps to actually locate where and how a hook is called before using it.
If you search the code base for
edit_form_after_editor
, you’ll locate:As you can see,
$post
is actually passed as an argument here. To access and use it without any chance of error, pass it to your function:To weed out non-posts, just go something like: