This function is working on php site but when I convert it to wordpress my menu links are not working and is adding another url. Here is an example of my url after I click one of my menu links: http://localhost/wordpress/#http://localhost/wordpress/
$(document).on("click", "#footer .menu a, .logo a", function(e) {
e.preventDefault();
var url = $(this).attr("href").replace("#", "");
window.location.hash = url.replace(".php", "");
if(!$(this).hasClass("no-ajax") && !$(this).hasClass("active")) {
$("#footer .menu a, .logo a").removeClass("active");
$(this).addClass("active");
$("#site-loader").fadeIn("medium", function() {
$("#main-content #main-content-load").fadeOut("medium", function() {
$("#main-content").addClass("transitioning");
$("#main-content").load(url + " #main-content-load", function() {
$("#main-content #main-content-load").fadeIn("medium", function() {
if(url == "index.php") {
initSlider();
}
if(url == "about-us.php") {
initAboutSlider();
}
$("#main-content").removeClass("transitioning");
$("#site-loader").fadeOut("medium");
});
});
});
});
}
$("#footer").removeClass("expanded");
});
These two lines are making that URL
var url = $(this).attr("href").replace("#", "");
window.location.hash = url.replace(".php", "");
What you are doing is adding a hashed location to to the current url, ie, you are redirecting http://localhost/wordpress/
to the anchor #http://localhost/wordpress/
If you are just trying to get the end file, you'll have to split apart url, perhaps:
var urlParts = url.replace(".php", "").split('/');
window.location.hash = urlParts[urlParts.length-1];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.