jquery-php magic: how to open the post page from within a homepage loop fancybox -


i run custom fancybox within wordpress; homepage loop grid of "featured images"; clicking on them doesn't open post page rather fancybox image post (usually there's one).

this done replacing the_permalink php function fetches direct url of (first) picture in post. far good.

now picture has opened in fancybox; here i've added beautifully working "print" link; need next it, link actual post page took image from!!

this hard me brains...

... how inform fancybox of such variable??

obviously, telling fancybox use <?php get_the_permalink(); ?> won't work (the php snippet converted url characters; besides, know postid? doubt it);

i tried different variants of ajax found on website similar purposes couldn't of them work. don't think on right track.

what's method? moment user clicks on fancybox link on home page, image url should sent fancybox script (for example) post id or post permalink, allow fancybox use such variables generate link.

at point simple window.location.replace(permalink); bound click action work. brain cannot see how can pass permalink or id fancybox. :(

sorry lack of code, i'll post think can help.

(n.b.: i'm using fancybox 1.3.7; customized insofar has print button , little similar changes, no big deal)

sorry answering own answer -- new :) anyway here ...by writing above post, helped brain figure solution this, rather straightforward:

fancybox uses lot of variables, not href; use 1 of them carry permalink through, example title, or add new variable (adding custom variable happen @ top of fancybox script, done:

_start = function() {         var obj = selectedarray[ selectedindex ],             href,              type,              title,             str,             emb,             ret;          _abort(); 

but i'm not trying now).

so have such situation, on php side:

<a class="fancybox-image" title="<?php echo get_the_permalink(); ?>"    href="<?php echo just_the_image(); ?>"> 

(the function just_the_image taking first image of post mentioned above)

then on jquery side, inside fancybox script, i'll (hope answer erik request well):

outer.append(permabox = $('<div id="#permabox"></div>')); 

and few lines down, bind action "permabox" thingy:

$('#permabox').bind("click", function(){ var mytitle = $('#fancybox-title-over').prop('innerhtml'); window.location.replace(mytitle);}); 

(notice title string, used innerhtml of fancybox; not straightforward way reckon);

the above not best solution, since fancybox in habit of displaying title under image; adding custom variable purpose, suggested above, better -- point is, above works :)


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -