Get page url after Ajax refresh

In wordpress I have a perticular bit of code in my functions.php…

function add_legend_explanation($html) {
  $categories = array(
    'category/1to1/', 
    'category/core/', 
    'category/couples/',
    'category/cpd/', 
    'category/international/', 
    'category/open/', 
    'category/organisational/'
  ); 
  $url = $_SERVER['REQUEST_URI'];
  $newurl = str_replace($categories, "", $url);
  echo '<a href="', $newurl, '">test me</a>' .$html;

This works great at removing the right section from the url.

Read More

The problem happens when I go to the next month in my calendar (which refreshes using ajax – the events calendar) when I click the next month, the end of the url (of the link “test me”) now becomes:

wp-admin/admin-ajax.php

(it’s running locally in xampp)

How do I fix this, as the URL bar shows the correct URL, I’m going crazy!

EDIT: OR can anyone show m how to change this from a php function to a working jquery function? Perhaps that will work better?

Related posts

Leave a Reply