The Grid - going back from a post to the page with the grid

Hello, I have the following problem: I have created a page “References” with “The Grid” for our multilingual website. Here our references are displayed as tiles. This also works wonderfully.Now when I click on a tile, the post (the single reference) opens in the same window. I now have a button at the bottom of the post (Back to the overview) with which I can go back to the References page. I do this with the following code (excerpt):

<div class="container">
        <div class="row">
            <div class="col-xs-12 back">
                <a href="<?php echo $_SERVER['HTTP_REFERER'];?>">
                    <?php
                    if (ICL_LANGUAGE_CODE == 'de') {
                        echo "Zurück zur Übersicht ";
                    } elseif (ICL_LANGUAGE_CODE == 'en') {
                        echo "Back to the overview  ";
                    } elseif (ICL_LANGUAGE_CODE == 'fr') {
                        echo "Retour à la vue d'ensemble ";
                    } elseif (ICL_LANGUAGE_CODE == 'es') {
                        echo "Volver a la vista general  ";
                    } elseif (ICL_LANGUAGE_CODE == 'nl') {
                        echo "Terug naar het overzicht ";
                    }
                    ?>
                </a>
            </div>

The problem is that I also refer to similar references in the post, when you click on them the whole thing doesn’t work anymore, because you only get to the previous page when you click on the button. Is there a way to always link to the “References” page with php, no matter from which post, or do I have to do the whole thing with static links?

Thank you in advance

Peter

Link: https://flashaar.de/en/references/

Hello Peter,

Thanks for writing to us.

I have visited the given URL, but unfortunately, not able to replicate the issue you are having. If that is related to HTTP_REFERER elements of $_SERVER variable. Please remember that the HTTP_REFERER actually holds the address of the page (if any) which referred the user agent to the current page.
In your case, there may not be any page from where you are coming to this page, and that is why it is not working properly.

Thanks

Hello, I have solved the problem for now. As you can see on the “similar-references” image it is possible to go from one post to another. And this is the point where my original solution didn’t work anymore. I have now changed the code as follows:

<div class="row">
            <div class="col-xs-12 back">

                    <?php
                    if (ICL_LANGUAGE_CODE == 'de') { ?>
                        <a href="https://flashaar.de/referenzen/">Zurück zur Übersicht</a>
                        
                    <?php } elseif (ICL_LANGUAGE_CODE == 'en') { ?>
                        <a href="https://flashaar.de/en/references/">Back to the overview</a>
                       
                    <?php } elseif (ICL_LANGUAGE_CODE == 'fr') { ?>
                        <a href="https://flashaar.de/fr/references/">Retour à la vue d'ensemble</a>
                        
                    <?php } elseif (ICL_LANGUAGE_CODE == 'es') { ?>
                        <a href="https://flashaar.de/es/referencias/">Volver a la vista general</a>
                        echo "Volver a la vista general  ";
                    <?php } elseif (ICL_LANGUAGE_CODE == 'nl') { ?>
                        <a href="https://flashaar.de/nl/referenties/">Terug naar het overzicht</a>
                        echo "Terug naar het overzicht ";
                    <?php }
                    ?>
                </a>
            </div>
        </div>

Now it works, I just thought there is a more elegant solution in php/WP!

Thank you for your help!

Sincere

Peter

Hello Peter,

Glad that you were able to solve your issue and I would also like to thank you for sharing the information with us. It will be helpful for our customer who wants to achieve similar features. Please free to reach us if you have any more concern regarding our theme and theme settings.

Have a great day!
Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.