Page Template - List data and send to another template

Asked

Viewed 31 times

0

Friends,

I am listing product data from a table created in the wp structure. I have created a "products.php" template where I list it like this:

produto 1
produto 2
produto 3
...

Each product of this will have a link that will point to another page with product item "products-item.php"

You can do this in WP with templates?

<a url="???">produto 1</a>

I will have to point to another template page (products-item.php)?

1 answer

1


You can browse the list of products by taking their ids and using them to compose the URL of produtos-item.php

<a url="produtos-item.php?id=$id">produto 1</a>

You will recover on the products-item.php page using the $_GET['id']

  • I did it, it worked great, thanks, but I’m thinking about the friendly url here. How do I put these friendly urls. I think I’ll have to create a Slug for each product.

  • Exactly, you save a Slug and then use . htaccess to remove the id, but recommend instead of removing leave on the default site.com/1/tv-lcd

  • can sweat site.com.br/product/1/product-a

  • I’ll try to do, thanks buddy.

  • 1 would be the id? with Slug I guess I wouldn’t need that id.

  • will give a work this gambiarra, the right would be to make a plugin. rs

  • You don’t need to, but the right one, in my view and always take product data by ID and only put Slug for SEO, because if you change Slug to something else, the ID doesn’t change and you don’t lose the reference to the page. You’ll never have an SEO problem. If you do not use error 404 ID you whenever you change the Slug of a product and we know that it always changes (at least my customers)

  • Vdd friend. Thanks.

  • Another obstacle has arisen here. besides the url has the issue of title, Description, Canonical, etc... on the product item page. I want to see how I’m going to do this, since I’m looking for something dynamic on a page that’s static.

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.