Support » Fixing WordPress » Where do I find what page template/php file a page is using?

  • kevintucker

    (@kevintucker)


    If I’m looking at a particular page, where can I find which .php file was used to generate the page, from the code of that page? I’ve been modifying the one that it would seem to be, but it’s not the right one, as my changes aren’t affecting it.

    For example, if I wanted to modify a single post page, I would change “single.php”, but this is one that was set up as a custom post type, and I’m modifying a file called “single-portfolio.php” based on an assumption, but it has no effect. So, clearly, I need to stop assuming, and simply find out which file it’s using to generate the page.

    But I can’t for the life of me figure out where to find this information from looking at the page code. Can someone please help me?

    Thanks!

Viewing 1 replies (of 1 total)
  • If you are trying to edit the single view of a custom post type, then it should either use single.php or if there is one, single-NAME-OF-POST-TYPE.php.

    There are a couple ways to figure out what template it’s using though. There’s quite a few of them in this thread with this looking pretty promising:

    global $wp_query;
    
    $template_name = get_post_meta( $wp_query->post->ID, '_wp_page_template', true );
Viewing 1 replies (of 1 total)
  • The topic ‘Where do I find what page template/php file a page is using?’ is closed to new replies.