0

I want to customize the footer text in a Custom Post Type admin page. I have a plugin that creates this custom post type and want to add in it a function to customize admin_footer_text.

As you can see in code below I can change the footer text, but only globaly.

function my_custom_footer_admin_text () {
    echo 'my custom message,';
}
add_filter('admin_footer_text', 'my_custom_footer_admin_text');

Does someone knows the hook of a custom post type page? Or how can I change the footer text of a certain Custom Post Type page?

  • What is a Custom Post Type page? Are you talking about post.php for that CPT? Or post-new.php? Or both? Or something else? – tfrommen Dec 23 '13 at 12:47
  • Hi, I'm talking about 'wp-admin/edit.php?post_type=my_post_type' and 'wp-admin/post-new.php?post_type=my_post_type'; pages. – eduardogoncalves Dec 23 '13 at 12:57
1

This should do. Put the following in your functions.php

if (in_array($GLOBALS['pagenow'], array('edit.php', 'post.php', 'post-new.php')))
    add_filter('admin_footer_text', 'my_custom_footer_admin_text');

function my_custom_footer_admin_text($text) {
    $post_type = filter_input(INPUT_GET, 'post_type');
    if (! $post_type)
        $post_type = get_post_type(filter_input(INPUT_GET, 'post'));

    if ('my_post_type' == $post_type)
        return 'my custom message';

    return $text;
}
0

There is number of functions related to working with post type, such as get_post_type() and is_singular().

Note that conditional tags are meant to be used primarily inside of running loop and in more complex sites $post global might no longer hold instance of post expected and require resetting via wp_reset_postdata() or something more elaborate, depending on what is going on in page.

  • He is talking about Admin footer... ;) – tfrommen Dec 23 '13 at 12:54
  • Oops. :) Logic roughly applies to loops in admin, but probably question has terminology mixed up after all... – Rarst Dec 23 '13 at 12:55
0

U can use

function my_custom_footer_admin_text () {

if(is_post_type_archive('custom-post-name')||is_singular('custom-post-name') ){

    echo 'my custom message,';
}

}
add_filter('admin_footer_text', 'my_custom_footer_admin_text');
  • But this will remove default footer in the other pages, and only worked to 'wp-admin/edit.php?post_type=my_post_type'. For the page 'wp-admin/post-new.php?post_type=my_post_type' it does not works. – eduardogoncalves Dec 23 '13 at 13:05

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.