php - Wordpress custom post type logic -


I created 2 custom post types (movies and actors), with more than one custom field.

For the actor, I have 3 custom fields (description, history, filmography) and I would like to display each custom field on a new page.

Pages / Actors /% From Actress% / I have 3 links:

  • www.domain.com/actor/%actorname%/details
  • Www.domain.com/actor/%actorname%/history
  • www.domain.com/actor/%actorname%/filmography

What is the logic behind this ? How can this be done?

Should I first create these pages and then manipulate the template? Any help would be great, I do not know where it starts with.

What you can do is give each actor an id, for example, for actor Brad Pitt ID is 1 and it is saved in your database.

Then when a user clicks the name of the actor, which you can place as a hyperlink, and you can redirect the user

  $ actor_id = / / Retrieve ID from database & lt; A href = "www.example.com/actor/history/?id=$actor_id" & gt; Brad Pitt & lt; / A & gt;  

Then you create a template

  & lt ;? Php / * ** Template Name: Visual Actor History Template * /? & Gt; & Lt ;? Php $ actor_id = $ _GET ['id']; // Retrieve data from the database, which is the history of the actor "Select the table history table WHERE id = $ actor_id"? & Gt; // your html tag here  

You also create a new page in your dashboard and use "View actor history template" instead of default template and note page slug ... you It uses " & lt; a href =" www.example.com/actor/page-slug "> actor's name & lt; / a & gt; "

Slug in

Comments