How to create a simple dynamic page from a plugin in wordpress

I know thw answer must be very simple, but I have been looking for weeks and I haven’t found straight forward answers.

I have built a plugin in wordpress that at a certain page, via a shortcode embedded, will display a list of names.

Read More

These names are coming from the database on an extra table, not wp.

I would then like the user to click on each one of these names and be directed to a dynamic page that has details about this person (the name just clicked).
The details would have to be populated via the plugin again by means of a few queries to those extra tables that are not wp.

I would just like to know how I create such page and make it generic so that I can use it over and over for all the list of people that I have.

I’ve tried making a new taxonomy and creating a custom template… but its getting very confusing and I’m sure this should be much simpler.

Can someone please help?

Related posts

Leave a Reply

1 comment

  1. You can keep everything on the same page with GET variables. Iterate over an array of persons and link the results to the current page, appending a query arg to each link:

    foreach( $persons as $person )
        echo '<a href="' . add_query_arg( array( 'person' => $person ), get_permalink() ) . '">' . $person . '</a>';
    

    You can then check if the variable is set, do some validation, and display the single person data:

    if( isset( $_GET['person'] ) && in_array( $_GET['person'], $persons ) ){
        // do stuff
    }