downloadTemp2014 2014-06-05 13:27
浏览 43
已采纳

将模板应用于自定义帖子类型Wordpress

I am trying to apply a template to a Custom Post Type in Wordpress. Currently I am displaying a list of Custom Post Types on a seperate page and I'm using the permalink for each post as the URL to go to when a link is clicked.

Code to generate the links:

<a href="<? echo get_post_permalink() ?>"><h2><?php the_title(); ?></h2></a>

This redirects me to a page with a URL like this:

http://xxx.xxx/?pa_supplier=xyz-packaging-ltd

I am wondering how I could customize how this page might look.

I know for pages you can create a php file called page-id.php and subsitute the page id in and that will allow for customization, can something similar be done to Custom Post Types?

  • 写回答

1条回答 默认 最新

  • dongpou1935 2014-06-05 13:41
    关注

    Simply create a new template file in the theme folder and name it with following syntax: single-[post-type_slug].php, for example. If we have a post-type named "projects", the file for displaying a single projects post would be "single-projects.php".

    Check the following link for more information: http://codex.wordpress.org/Template_Hierarchy

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错