I have created a media button as such:

    // Create a media button for pages
function aisis_page_button_link(){
    global $post_ID, $temp_ID, $iframe_post_id;
    $iframe_post_id = (int) (0 == $post_ID ? $temp_ID : $post_ID);
    $url = admin_url("/admin-ajax.php?post_id=$iframe_post_id&codes=aisis-page-codes&action=aisis_page_codes&TB_iframe=true");
    echo "<a href='".$url."' class='move thickbox' title='Create amazing pages with these codes!'>
    <img src='".get_template_directory_uri() . "/lib/images/pages.png" . "' width='16' height='16'></a>";

if(!empty($_GET['codes']) && $_GET['codes'] == 'aisis-page-codes'){
    add_action( 'parse_request', 'parse_wp_request' );
    echo parse_aisis_page_request($wp);
    add_action( 'wp_ajax_asisi_page_codes', 'parse_aisis_page_request' );

function parse_aisis_page_request($wp){

function aisis_require_page_code_display_page(){
    require_once(CORETHEME_SHORTCODES . 'PageCodes.phtml');

add_action('media_buttons', 'aisis_page_button_link', 999);

Which then creates the desired effect of:

enter image description here

Note: The above code is for the second "page" like icon.

What I want to do is only have the above code run on pages, and only pages. that is edit and add new page. I know I would edit the aisis_page_button_link() function, and I can figure out how to make it appear for adding a new page, how ever how do you make it appear for editing a page?


Check the post type:

function aisis_page_button_link(){
    global $post_ID, $temp_ID, $iframe_post_id;

    if ( 'page' !== get_post_type( $post_ID ) )

    // continue
  • interesting. thnx – TheWebs Apr 4 '13 at 19:13

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.