我创建了2种自定义帖子类型(电影和演员),每种类型都有多个自定义字段。
对于演员,我有3个自定义字段(详细信息,历史记录,影视作品),我想在新页面上显示每个自定义字段。
从页面/ actor /%actorname%/我将拥有3个链接:
这背后的逻辑是什么?如何才能做到这一点?
我是否首先创建这些页面,然后操纵模板?任何帮助都将是巨大的,我不知道从哪里开始。
您可以做的是为每个演员指定一个ID。例如,演员布拉德·皮特(Brad Pitt)的ID为1,并将其保存在您的数据库中。
那么每当用户单击actor的名称时,您可以将其作为超链接放置,然后可以将用户重定向到
$actor_id = //retrive the id from the database
<a href="www.example.com/actor/history/?id=$actor_id">Bradd Pitt </a>
然后创建一个模板
<?php
/*
** Template Name: view actor history template
*/
?>
<?php
$actor_id = $_GET['id'];
// retrieve data from database , that is history of the actor as
"SELECT history FROM table_actor WHERE id = $actor_id"
?>
// your html tags here
同样,在您的信息中心中,您将创建一个新页面,并使用“查看演员历史记录模板”而不是默认模板,并注意页面上的标签...您在“ <a href="www.example.com/actor/page-slug">Actor name </a>
”中使用了该标签。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句