L
L
Legal Adviser2019-05-14 20:38:31
PHP
Legal Adviser, 2019-05-14 20:38:31

How to link to different pages in one template?

There are pages: " product 1 " and " product 2 ".
Each of these pages lists products ("product 1.1", "product 2.1", etc.).
When we go to the "product 1.1" page, we get the following address: Therefore, when we go to the "product 2.1" page, we get the following address: On each page ("product 1.1/2.2", etc.) there is a link "back to all products" . The page template ("product 1.1" and "product 2.2", etc.) is the same. Question: How to correctly create a "return to all products" link code in wordpress so as not to make two identical templates (files) and not to prescribe the ID of the corresponding category according to the principle
http://example.ru/товар 1/товар 1.1
http://example.ru/товар 2/товар 2.1

<?php
echo '<a href="' . get_permalink(1) . '">вернуться ко всем товарам 1</a>';
?>
<?php
echo '<a href="' . get_permalink(2) . '">вернуться ко всем товарам 2</a>';
?>

5cdafcfbaae48924064008.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2019-05-14
@deniscopro

get_permalink( wp_get_post_parent_id() )
?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question