php - Wordpress: Use title (slug) in hashed URL instead of post ID -
i developing wordpress site hope load content using ajax. seem have working although i'm not sure how code is! issue hash display post title (slug) in url (address bar) instead of post id haven't been able figure out.
can offer advice, thanks
$(document).ready(function(){ $.ajaxsetup({cache:false}); $(".post-pop").click(function(){ var post_url = $(this).attr("href"); var post_id = $(this).attr("rel"); $('body,html').animate({scrolltop: 0}, 800); $("#your_post_here").load("http://<?php echo $_server[http_host]; ?>/blog-post/",{id:post_id}); window.location.hash = post_id; return false; }); if(document.location.hash!='') { var hashval = window.location.hash.substring(1); $('body,html').animate({scrolltop: 0}, 0); $("#your_post_here").load("http://<?php echo $_server[http_host]; ?>/blog-post/",{id:hashval}); return false; } });
Comments
Post a Comment