TL;DR
Hello, is there any way to get wordpress the_permalink on script something like echo and load it on jquery with working on all posts separately?
Long version:
Hello, In wordpress I’m trying to make my posts look like image thumbnail and when I hover over them it shows the title and category of the post. And how i’m doing that is when i hover the div that has image_thumb .show script runs. I want it to make like when i click on any place of the image it goes to the post link. and when i click on the category it goes to category. since i cannot use another link inside link. i made the imagethumb div go to links with “.click function” but i can’t use because java cant directly run php. So is there anyway i can get the correct link maybe like echoed somewhere and get the link and load it?
here’s my jquery:
$(document).ready(function(){
$(".select").hover(
function(){
$(this).find('.caption').fadeIn(500);
},
function(){
$(this).find('.caption').fadeOut(500);
}
);
$(".select").click(function(evt){
window.location = '<?php the_permalink(); ?>';
});
});
There should be more elegant solution, but a quick roundup is to use server-side code to export your required link as a “data-blablah” attribute of this div, then use jQuery to catch it.
For example, a link may look like
<a href="original/path" title="blah" class="select" data-permanlink="wanted/path">Then you can use jQuery to catch this attribute and header to it, something like this: