title: How to change a wordpress post url dynamically without url re-write rule
body: <p>I have a <code>$postURL</code>, which basically contains a wordpress post url. I retrieve it as follows:</p>
  
  <pre><code>$postURL = get_permalink($postID);
  </code></pre>
  
  <p>Now suppose this $postURL is: </p>
  
  <pre><code>http://www.blogname.come/post-permalink/
  </code></pre>
  
  <p>I want to change this to </p>
  
  <pre><code>http://www.blogname.come/post-permalink-1/
  </code></pre>
  
  <p>i.e. add a <code>-1</code> at the end of the $postURL and add it to a new variable <code>$newURL</code>.</p>
  
  <p>// Function to include required JS and CSS in header
  function wplikelockercss() {</p>
  
  <pre><code>// Include the CSS
  echo "&lt;link type=\"text/css\" rel=\"stylesheet\" href=\"".get_bloginfo('wpurl')."/wp-content/plugins/".basename(dirname(__FILE__))."/like-locker.css\"&gt; \n";
  //$postID = $_POST['post'];
  $postID = get_the_ID();
  $postURL = get_permalink($postID);
  $newURL = substr($postURL, 0 -1). "-1";
  //$newURL = "1-".$postURL;
  
  
  // Echo our per page post ID callback from facebok, when the user clicks like this function will be triggerd and their IP will be stored in the databse with the post ID
  echo "
  &lt;script type=\"text/javascript\"&gt;
  
      FB.Event.subscribe('edge.create', function(href){ 
  
          var data = { post: '".get_the_ID()."', action: 'fbjax' };
  
          jQuery.post('".admin_url( 'admin-ajax.php' )."', data, function(response) {
  
              //location.reload();
              //location.href='http://www.blogname.net/how-thing-work-1';
              location.href='$newURL';
  
          });
  
      });
  
  &lt;/script&gt; \n
  ";
  </code></pre>
  
  <p>}</p>
  
  <p>The code that I have in place is provided above. I am getting the $postID, fetching the $postURL and then trying to create a newURL. The location.href then uses this $newURL to redirect users to a new page. </p>
  
  <p>However, if is use</p>
  
  <p>$newURL = substr($postURL, 0 -1). "-1";</p>
  
  <p>The $newURL is</p>
  
  <p><a href="http://www.blogname.net/e-1" rel="nofollow">http://www.blogname.net/e-1</a> or someother character before -1</p>
  
  <p>If i use</p>
  
  <p>$newURL = "1-".$postURL;</p>
  
  <p>The location.href redirects page to</p>
  
  <p><a href="http://www.blogname.net/1-" rel="nofollow">http://www.blogname.net/1-</a></p>