0

Which hooks can I use to add my own HTML stuff to a CPT edit screen? I created an own CPT with

$args = array (
    'labels' => array (
        'name'          => 'Catalog',
    ),
    'capability_type'   => 'post',
    'has_archive'       => true,
    'public'            => true,
    'show_in_menu'      => true,
    'rewrite'           => array ( 
        'slug'  => 'catalog' 
    ),
    'supports' =>   array (
        'title', 
        'thumbnail' 
    ),
);

register_post_type( 'catalog', $args );

I use only the featured image for the rest I removed all default things like title editor... You can see this in the support array in my code above.

Now I want add my own HTML stuff to this editpage

5
  • are you referring to the classic editor or the block editor?
    – Tom J Nowell
    Mar 19 at 23:40
  • @TomJNowell the classic editor
    – Jop
    Mar 19 at 23:41
  • What exactly are you trying to do that requires this? What's the context?
    – Tom J Nowell
    Mar 20 at 12:44
  • With my own HTML I have more control. I want create my own form and I don't need the default input fields. I thought it was easy to do just like a calback page for add_admin_menu.
    – Jop
    Mar 20 at 18:41
  • So you don't just want to add things, you want to remove things too? I ask this because there are multiple hooks and filters, but which one to use depends on what you want to do. By keeping your answer as generic as possible you make the question much harder to answer. People answering would have to write a comprehensive answer that covers every possible use case for every possible situation, which could take hours. Add more context and be more specific in your question, state what you are trying to replace, and what you're replacing it with
    – Tom J Nowell
    Mar 20 at 18:52
0

I found a solution

add_action('edit_form_advanced', 'add_to_admin_cpt');

function add_to_admin_cpt() {
    global $post;
    if ($post->post_type == 'catalog') {
        //doing my own stuff
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.