Pass post title as URL parameter

admin2025-01-07  4

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

/

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. /?xxx=my-great-post

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

What's the best way to accomplish this?

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?

Share Improve this question edited Apr 21, 2017 at 12:23 Galwegian asked Apr 21, 2017 at 11:48 GalwegianGalwegian 1013 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736263566a901.html

最新回复(0)