Pass post title as URL parameter

On my site/blog, I have one landing page, through which I collect all ‘Consultation Requests’ – let’s call it:

http://example.com/conso-request/

On every page/post of the site is a navigation link, with the text ‘Request Information’.

For each page/post that CTA appears, I want it to have a unique URL which passes the post/page title to my landing page, e.g. http://example.com/conso-request/?xxx=my-great-post

I've got the element id to work with btw.

What's the best way to accomplish this?

Topic urls Wordpress parameter

Category Web


I think adding the new link by hook will be the best way.

function new_nav_menu_items($items) {

    global $post;
    $post_slug=$post->post_name;

    $landinglink = '<li class="home"><a href="' .get_page_link('YOUR_LANDING_PAGE_ID_HERE').'?from='.$post_slug.'">' . __('BLAA') . '</a></li>';
    $items = $items . $landinglink;
    return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );

Change 'YOUR_LANDING_PAGE_ID_HERE' with landing page ID. Cheers

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.