Get Name of the Current Template File |

Congrats, You are Subscribed to Receive Updates.

Get Name of the Current Template File

Get Name of the Current Template File. In wordpress, you need to edit certain posts and pages based on the page template and ID of the template.

Here I have small code snippet to get the current page, page template.  Before getting into the page template work, we need current page or Post ID to query the current post template.  Let’s begin with  code.

<?php $kv_post_id = get_the_ID(); ?>

The above one  get the current post or page id,  with the help of the function we are going to get the page template.

global $wp_query;

$template_name = get_post_meta( $kv_post_id, '_wp_page_template', true );

This how, you can retrieve the page template name and its details.

Any doubts and problem in implementation, drop your comment below.


About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

Comment Below

Your email address will not be published. Required fields are marked *


Current ye@r *