-
AuthorPosts
-
November 29, 2019 at 2:52 pm #1161237
Hello,
when I choose custom link in the portfolio item, only the image is clickable (the title has no link). How can I make the whole entry box clickable?December 3, 2019 at 1:27 pm #1162193Hey netzhautflimmern,
Thank you for the inquiry.
Add this script in the functions.php file to apply the link to the whole grid entry.
add_action('wp_footer', function() { ?> <script> (function($) { $(document).ready(function() { $('.grid-entry').on('click', function() { window.location.href = $(this).find('grid-image').attr('href'); }); }); })(jQuery); </script> });
And this css code to show a link pointer when you hover the portfolio entry.
.grid-entry { cursor: pointer; }
Best regards,
IsmaelDecember 4, 2019 at 3:23 pm #1162631thanx. When I nisert it into function.php I get the following error:
syntax error, unexpected end of fileDecember 4, 2019 at 9:14 pm #1162731hm try this instead:
function shift_link_to_grid(){ ?> <script type="text/javascript"> (function($) { $(document).ready(function() { $('.grid-entry').on('click', function() { window.location.href = $(this).find('.grid-image').attr('href'); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'shift_link_to_grid');
December 4, 2019 at 11:09 pm #1162749this works, but, in case I have an entry with a manual link to a pdf or an ajax, when I click on the entry outside the image, it opens a new page link: /undefined
December 5, 2019 at 10:31 am #1162864bei deinem Nick gehe ich mal davon aus, dass du Deutsch sprichts.
Hast du mal einen Link worum es geht. In deiner Beschreibung oben fehlen ein paar Informationen um es nachzubauen.
Da ist ein Link immer besser um Ratschläge zu geben.December 5, 2019 at 10:33 am #1162866Hallo, ja genau ;)
Schau mal hier: https://adlatus.netzhautflimmern.ch/#blog
Der normale Link auf dem Bild geht zum Artikel, aber wenn ich in den Rest des Kästchens klicke, ist dort jetzt zwar ein Link (nachdem ich die Funktion eingefügt habe), aber der geht ins Leere.
Also Funktion geht, aber Link wird falsch gesetzt.- This reply was modified 5 years ago by netzhautflimmern.
December 5, 2019 at 10:49 am #1162874Hi,
Danke fur das Update.
There is a little syntax error in this line.
window.location.href = $(this).find('grid-image').attr('href');
There should be a dot before “grid-image” because it’s supposed to be a class selector.
window.location.href = $(this).find('.grid-image').attr('href');
It should work propery now.
Best regards,
IsmaelDecember 5, 2019 at 10:52 am #1162875yes i changed it allready on my post above – transmission errors ;)
December 5, 2019 at 10:53 am #1162876perfect, works fine now. thank you very much!!
December 5, 2019 at 11:04 am #1162879really ?
December 5, 2019 at 11:09 am #1162880yeah, already works as I wanted. thank you!!
December 5, 2019 at 11:29 am #1162891click on one link please of the blog ( on the bottom or text )
December 5, 2019 at 12:11 pm #1162914ah you’re right, it seems to work for all kind of links except the ajax.
check https://adlatus.netzhautflimmern.ch/#referenzen
it opens a new window instead of ajaxDecember 5, 2019 at 1:44 pm #1162975so we had to make the changings only for not ajax protfolios – try this instead please:
function transfer_link_from_child(){ ?> <script> (function($){ $(document).ready(function(){ $('.grid-sort-container:not(.grid-links-ajax)').find('.grid-entry .inner-entry').each(function(){ var theLink = $(this).find('.grid-image').attr('href'); $(this).addClass("clickme"); $(this).on("click", function(){ window.location.href = theLink; }); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'transfer_link_from_child');
i styled it this way:
.clickme:hover { cursor: pointer; -webkit-filter: drop-shadow(2px 3px 5px #999); filter: drop-shadow(2px 3px 5px #999); }
i changed the code to containter with .inner-entry class because if you got padding on those the styling could be more precise
December 5, 2019 at 1:48 pm #1162977you can see results here on my test-page: https://webers-testseite.de/portfolio/
Edit : i’m still experimenting a bit – so the example page could be not of the intended function.maybe Ismael knows a method to do it for that ajax setup too. Without that selector only for non ajax grids the click on ajax has two click events and does open first the window above the grid – but directly moves to the single portfolio.
- This reply was modified 5 years ago by Guenni007.
December 6, 2019 at 3:41 pm #1163403Hello, thank you.. so this works now for all kinds of portfolio, just the ajax is only working on the images right?
December 6, 2019 at 3:58 pm #1163407you see the code above the selector is: grid-entry but to exclude the ajax thing i find it via grid-sort-container
and to exclude the ajax option there is the not rule
this is only for grid layoutDecember 6, 2019 at 4:18 pm #1163412ok, so is there a solution, that includes the ajax or is there no possibility?
December 9, 2019 at 4:22 am #1163956Hi,
Thank you for following up.
The latest script @Guenni007 provided above should work. The portfolio grids that were set to AJAX will work as is, or they will not be affected by the modification.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.