Give Wordpress custom page template a title for ap

2019-08-13 00:38发布

问题:

When in Wordpress theme appearance editor, certain pages have a neat titles displayed in the right hand list for your theme files.For example page.php shows as "Page Template". This is clean and easily read.

Is there any comment syntax that Wordpress uses to give these titles for my custom page template?

For example, my single-video.php page could be "Video Page Template".

回答1:

Yes you can. Make sure your page opens with something like:

<?php /** Template Name: Text & Image 
*/ get_header(); ?>

In this case the name of the file in your file overview (while in your appearance editor): Text & Image Page Template



回答2:

I don't think so. The reason being that single-{type} pages are not essentially a required part of WordPress Template files, where as page.php is as it is used to for all static WordPress pages.

So it makes sense that WordPress people set a neat title for page.php and left single-{type} pages unattended. Also, type of single-{type} pages are user defined and subject to variation; where as page.php templates are not.

You may refer this page from WordPress Codex for more information



回答3:

Yes, you need to provide a proper formatted URL (permalink) to wordpress Like either you want a dash (-) OR Forward Slash (/) OR whatever you want.

For this Go to Admin Panel > Appearance > Permalinks, here you can see the different styles of permalinks.You can create your own permalink structure too.

Find the attachment for your help.