Is there a WordPress plugin that registers a plugin file as a custom page template?

I need to create a plugin that makes custom page templates available in wp-admin. I’m wondering if someone has tackled this already, as it seems like a pretty typical process? 4 s 4 Like Rarst answered you can really do that without editing core files or remove the page attributes metabox and create your on … Read more

A check for if is parent page, if has children, if has grandchildren

I have one default page template that I wish to use for two scenarios. I’d prefer to use only one page template for the sake of simplicity for my client. Here’s what I’m trying to accomplish: if parent_page OR if child-page without children { display full-width-layout } if child page with children or if grandchild … Read more

How to move page template files like page-{slug}.php to a sub-directory?

I want to move page template files like page-{slug}.php to a sub-directory within my theme, in a way that WordPress will recognize them automatically. If the page templates of the said form doesn’t exist within the sub-directory, then WordPress should fall back to the default template loading rules. How can I achieve that? Note-1: This … Read more

Conditional tag to check if ‘page.php’ is being used?

I’m trying to check whether the page.php template is being used or not. I’ve tried is_page_template( ‘page.php’ ) but it doesn’t work. I also can’t use is_page() because I only want to do something when page.php is used, and not when some other custom Page template is used. Please let me know about this and … Read more

What does is_page_template() compare against?

Looking through the WordPress documentation, it says that is_page_template() compares against a “template name”, if one is provided. I have a template stored in page-homepage.php called Homepage: /* * Template Name: Homepage * Description: The template for displaying the homepage */ And I have some code I wish to run in my functions.php when I’m … Read more

How to display page content in a page template?

In my WordPress site, I made a custom page template, which contained a custom query [using WP_Query()]. With that query, I can perfectly get the posts of a certain category. But I want to show the page contents along with the queried posts. Thing will be like: ————————— Page Heading page contents Queried Post Heading … Read more