• Hello,

    I’m looking into editing the backend, and would like to have a date picker for the title field, but only for custom post type called recommendations.

    I’m loading an extra js file to do it (from functions.php), but can’t target the recommendations post type.

    This isn’t working:

    function customAdminJavascript() {
      $admin_script_url = get_settings('siteurl');
      $admin_script_url = get_stylesheet_directory_uri() . '/js/admin-script.js';
      echo '<!-- custom admin javascript -->
              <script src="' . $admin_script_url . '"></script>
            <!--/custom admin javascript -->';
    }
    //Try to spew it out in the header only when editing/writing a recommendation
    if ('recommendations' == get_post_type()) {
      add_action('admin_head', 'customAdminJavascript');
    }

    What sort of conditional statement I should use?

    Thanks for all the help 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter hilj

    (@hilj)

    Sorry for bumping so early but anybody have a glue? Cheers.

    Thread Starter hilj

    (@hilj)

    Found an answer to this, with one drawback, it does not effect when editing the custom post type. It’s good when viewing the custom post type archive page and when creating a new page.

    if ((isset($_GET['post_type']) && $_GET['post_type'] == 'recommendations') || (isset($post_type) && $post_type == 'recommendations')){
      //do stuff
    }

    Can anybody help? Thanks 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘do stuff if is custom post type, on admin view’ is closed to new replies.