Reply To: Open lightbox from included anchor

Your Account / Forums / Easy FancyBox Pro / Open lightbox from included anchor / Reply To: Open lightbox from included anchor

January 11, 2016 at 10:01 pm #5986

I’m not completely sure if I understand correctly so tell me if I’m wrong…

If I go to the example page you you gave earlier then I suppose each item there is created from a Portfolio Post with a Featured Image, a title and a short text. Correct?

Is that part of the theme or is that a plugin? And did you already modify the theme/plugin so that these items link not to the portfolio item itself but to the large image version or was that already the case?

In any case, to make it work, you’ll have to modify the theme/plugin to include an ID for each item link there. This ID can simply be done by adding something like

id="resource-<?php echo get_the_ID() ?>"

in the correct place in the corresponding template file. Note that (1) this only works inside a Loop and (2) an ID in HTML may not start with a number, hence the prefix.

The resulting link source should then be like

    <a class="w-portfolio-item-anchor" id="resource-12531" href="..."

Then, since you’re modifying the template already, find a good spot outside the loop where you can add

<script type="text/javascript">
window.onload = function() {
if(location.hash) { jQuery(location.hash).trigger('click'); }

so that it only occurs once on the resulting page source.

From then on, each item can be triggered with a corresponding URL like