Give Wordpress custom page template a title for appearance editor

試著忘記壹切 提交于 2020-01-05 19:42:08

问题


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.



来源:https://stackoverflow.com/questions/18809404/give-wordpress-custom-page-template-a-title-for-appearance-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!