First off, sorry for the long read. But I hope that this better explains what I'm trying to do...
I'm probably trying something that cannot be done. But I'll ask the question anyway.
I got a custom post type (beachevents) in this custom post type I have my beachevents-posts. There all in the loop loop-beachevents, don't know if that matters anything, but ok.
I also have some locations like Noord Holland, Zuid Holland and Flevoland. Locations is a custom taxonomy (locations_noord_holland, locations_zuid_holand etc.)
The taxonomy locations_noord_holland is filled with cities in Noord Holland, like Amsterdam for this question.
When you go to Home -> Locations -> Noord Holland -> Amsterdam URL is: home.nl/locaties/noord-holland/amsterdam (where amsterdam is the Slug).
In this screen have some text about the beachevents in Amsterdam. Also it Gets the slug Amsterdam with the following code:
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?>
With returns "Beachevents in Amterdam" as the title.
Ok now for the code part. When you click on a beachevent in Amsterdam it will link you to home.nl/activiteiten/your-beachevent/ (activiteiten is a custom post type rewrite from the custom post type beachevents)
On that page there is a hidden contact form7 which is activated using fancybox. Using this code:
<a class="my-subject fancybox-offerte" href="#offerte" dataTitle="<?php echo $subject; ?>"><div class="btn btn-04">Offerte aanvragen</div></a>
The dataTitle is there so the contact form7 know what beachevents is selected and automatically sets this value in the contact form as "beachevent" this all works in combination with the "Dynamic Content plugin in for Contactform 7".
So, that explains the lot. Now what I would like is to have Wordpress remember from what slug (in this case Amsterdam) the user came from and add this city to the contact form using the dynamic content plugin.
What I know is that I have to tell Wordpress to remember the slug Amsterdam (or any other city from Noord Holland, Zuid Holland or Flevoland). And store this value in any form so the contact form knows where to put this information.
In the contact form I can add the following:
<li class="low-li">[dynamictext text-uitje id:txt-uitje class:dy-text "CF7_ADD_CITY"]</li>
And then I add this code to my function file:
function cf7_add_city() {
global $post;
$city = get_field('stad');
return $city;
}
add_shortcode('CF7_ADD_CITY', 'cf7_add_city');
But this only works if i set the city in some advanced custom field and get it's value. But this does not get the (dynamic) slug that I would like to have Wordpress remember from the previous page.
Can anyone help me with this? Is this at all possible?