Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So my wordpress site has a one header and one footer with a big CTA as one of the menu items. I want to create a bunch of landing pages but I want to be able to change the offerid in the url for each landing page for that big CTA so I can track.

By offerid I mean http://www.example.com/customers/?offerid=weyhw68963.

I'm am stuck on how to do this since the menu is a global menu and the link is the same on every page. My thought is that I would make a condition in the header.php file because I'm using bootstrap and I activated the menu in the header file.

    <?php
    if(is_front_page()) {
        $args = array(
              'menu'         => 'header-menu',
              'menu_class'   =>'nav navbar-nav navbar-right',
              'container'    =>'false'
              );
      } else {
        $args = array(
              'menu'         => 'page-menu',
              'menu_class'   =>'nav navbar-nav navbar-right',
              'container'    =>'false'
              );
      }
      wp_nav_menu( $args );

     ?>

I'm thinking something like starting with is_page("offerid") then using custom_key but to be honest I'm very lost.

share|improve this question

1 Answer 1

What about using jQuery to insert the unique code to your CTA menu class or item ID? Something like:

    // generate your unique codes in jQuery
    var mycode = your_random_code_function() // or an array of codes
    // then…
    var myhref = $("body.landingpage .navbar-nav .cta a").attr("href"); 
    $("body.landingpage .navbar-nav .cta a").attr("href", myhref + "?offerid=" + mycode);
    // etc…
    // add the .cta class to the menu item that needs a code via Appearance > Menus in WP
    // or just use its WP generated ID

Otherwise I think you'd have to look at a custom walker class.

share|improve this answer
    
I would love to find a way to have it so that I can just add the offerid to a custom field of each page and it automatically generates at the end of the url –  Bs3kg Jul 29 at 13:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.