I have a website on WordPress, there is an API travel agency.
On the main page, I use the for
loop to display information on up to 6 last minute tours in the form of blocks. I need that when clicking on each block, single-page
opens with the same markup for each block, but with different information and, accordingly, url
!
In the likeness, if I had an archive page and on it I showed single
posts.
2 answers
Create 6 pages for 6 burning tours, give them the same template. They will have different url.
Learn more about creating templates in WordPress: https://wp-kama.ru/id_5177/3-sposoba-sozdat-shablon-stranitsyi.html
- Not an option, the page should be one, with different content, it may be that in the future there will be 4 blocks, and then 15, etc. - Artyom Pilipchuk
- What does it mean - "the page should be one, with different content"? How do you imagine this in the admin panel? And the base? It seems that you are not quite clear what you want. - KAGG Design
- Maybe I put it wrong, but creating pages for each tour is nonsense, now there are only one quantity, tomorrow another. It is necessary to do something like rewriting the link in which some value will be transmitted (for example, ID), and the content that corresponds to this ID will be displayed on the page! - Artyom Pilipchuk
In general, I solved the problem in the following way; maybe it will be useful to someone:
Created 2 pages of hot-tours
and tour
, the first page is supposedly an archive page, the second subsidiary is single.
Using add_query_arg
set the parameters for the previously created page.
$arr_params = array('key' => $tour_key[$i]); $new_url = esc_url(add_query_arg($arr_params, 'http://localhost:3000/hot-tours/tour/'));
We get this URL here - http://localhost:3000/hot-tours/tour/?key=123
separately for each block, separate value for the key key
. Accordingly, we have one template page - it is hot-tours/tour/
but the content is different and the url is also, thanks to the parameters that are passed via add_query_arg
.
Well and further through query_vars
get a key and on it already we do request to API and we pull out necessary for each round.
- oneIf you need dynamic pages with arbitrary names, you can use my answer to this topic: ru.stackoverflow.com/a/922415/220220 - KAGG Design