• This works to retrieve the pages template when viewing the page by calling a function like this:

    global $wp_query;
    $template_name = get_post_meta( $wp_query->post->ID, '_wp_page_template', TRUE );
    $template_name = str_replace( '.php', '', $template_name );

    but it doesn’t work when called in the admin panel when the same function is invoked using the filter below:

    add_filter('tiny_mce_before_init', 'winners_bingo_tiny_mce_before_init');

    Is there a way to get the pages template name so I can add a special class to the body class of TinyMCE? This technique works using the filter and function above for everything but I just can’t retrieve the template for the page being edited???

    Anyone know how to do this?

Viewing 1 replies (of 1 total)
  • Thread Starter mtpultz

    (@mtpultz)

    Figured it out:

    // get post id from viewed page
    $post_id = $wp_query->post->ID;
    
    // does post id exist?
    if( !$post_id )
    {
    	// get post id from admin page
    	$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘How to get template name of page being edited?’ is closed to new replies.