Reputation: 149
I am using an API to pull in information and I have it working where I pull in a list of all of my products. Now what I'd like to do is create a link that is something along the lines of "/products/product-id/" where the product-id is generated from the feed. That is complete.
My issue is creating a page-template that will be associated with those pages. I know that if those pages were part of a post type I could simply create a page template like single-products.php but that doesn't work. So my question is how would I create a template that goes with that page?
I know a work around would be to create a post type and then create the pages in the dashboard with the url of the product ID but there has to be a way to do that dynamically right?
Upvotes: 2
Views: 5203
Reputation: 149
I solved this. What I did was create a new page "product" and assigned a template it to it like any normal page. Then on my links to that page I passed a variable with /product?id=. Then in my template for the new page I did
$id = $_GET['id'];
$url = "http://link.com/products/$id";
This allows me to pass new variables into the new page and dynamically populate it with the individual products info.
Upvotes: 4