Home › Forums › Pro Support › custom link or none?
- This topic has 9 replies, 3 voices, and was last updated 6 years, 2 months ago by
Tom.
-
AuthorPosts
-
December 22, 2016 at 1:06 pm #1293
dasigna
Participanthi tom,
fiddling around again with this neat little plugin, and there are questions occuring … 🙂
so i’m tying to set up a page/list with images for sponsors (logos) and WPSP does the job well so far… but the link thingy is one to solve.
as these are logos for sponsors, theres no use to link to the ‘post’-page and therefore set this one to ‘image lightbox’. that prevents the senseless link in this case, but the image shown separately is not much better – so the question would be, if there is any way to completely disable this link for this special list?? or even better maybe replace it with the links to the sponsors homepage??trying to solve this ‘issue’ theres another thing that comes in mind when trying to use a custom link – the sponsors logos are cpts an can have custom fields, e.g. for weblink to homepage. is there any chance to get a grip on these custom fields from within WPSP?? would be quite awesome!!
kind of have to solve this thing in a appropriate way, and cpts seem to be the best thing because the sponsors have to be sorted too, and everything doing manually is getting much too complicated for users, so there has to be an (mostly) automated way.
thanks for help in advance.
December 23, 2016 at 12:22 am #1294Tom
KeymasterThere’s a filter you can use: wpsp_image_href
add_filter( 'wpsp_image_href','tu_change_wpsp_image_href' ); function tu_change_wpsp_image_href( $url ) { $custom_url = get_post_meta( get_the_ID(), 'my_custom_field_url', true ); if ( is_page( 'your-page-slug' ) && '' !== $custom_url ) { return $custom_url; } return $url; }
That assumes you have a custom field called “my_custom_field_url” in your post.
Let me know if you need more info 🙂
December 23, 2016 at 3:29 am #1295dasigna
Participant…
so thats tom – asking if its possible, and theres not only the answer’yes’ – you also provided already with code. second to none 🙂
but unfortunately it wont work. even if i set the is_page condition to every page it wont do. hmmm…
the field-slug is correct obviously, so i am running out of ideas.
maybe its due to the field created by ‘wp-types’ plugin? … have to fiddle a bit again later and hope to get it working somehow. but functions are not my favour indeed.thanks so far – great support as always.
December 23, 2016 at 6:32 am #1296dasigna
Participant… got it! 🙂
was indeed due to wp-types – the cpt-slug needs a special prefix to work this way. so why should be easy when things can be more complicated …but one thing is missing and didnt get to work so far ist to target the link to _blank. any hints?
December 23, 2016 at 12:15 pm #1304Tom
KeymasterYou might be able to use the wpsp_image_data filter..:
add_filter( 'wpsp_image_data','tu_add_image_data' ); function tu_add_image_data( $data ) { if ( is_page( 'whatever' ) ) { $data = 'target="_blank"'; } return $data; }
December 23, 2016 at 12:49 pm #1306dasigna
Participant…! fiddled around for dont know how long with the code you provided before, and tadaaa: here it is again – proper solution, working like a charm.
tom, again leaving me speechless. big thanks.
merry christmas to you and you family!
December 23, 2016 at 11:53 pm #1312Tom
KeymasterAwesome, glad I was able to help!
Merry Christmas to you and your family as well 🙂
January 23, 2017 at 7:31 am #1490Alexander Seboe
ParticipantAnother method: If you want to remove the links from a list, you can include a jquery in the header.php of you child theme.
<script> jQuery(document).ready(function(){ var pTags = jQuery( ".home section#wpsp-65 article div.wp-show-posts-inner div.wp-show-posts-image a img,.home section#wpsp-11 article div.wp-show-posts-inner div.wp-show-posts-image a img,.home section#wpsp-50 article div.wp-show-posts-inner div.wp-show-posts-image a img" ); if ( pTags.parent().is( "a" ) ) { pTags.unwrap(); } }); </script>
March 14, 2017 at 6:06 am #1760Alexander Seboe
Participant<script> jQuery(document).ready(function(){ var pTags = jQuery( ".home section#wpsp-65 article div.wp-show-posts-inner div.wp-show-posts-image a img, .home section#wpsp-11 article div.wp-show-posts-inner div.wp-show-posts-image a img, .home section#wpsp-50 article div.wp-show-posts-inner div.wp-show-posts-image a img, .page section#wpsp-247 article div.wp-show-posts-inner div.wp-show-posts-image a img" ); if ( pTags.parent().is( "a" ) ) { pTags.unwrap(); } var tTags = jQuery( ".page-id-255 div#page div#content div#primary main#main div#generate-section-2 div.generate-sections-inside-container section#wpsp-247 article div.wp-show-posts-inner header.wp-show-posts-entry-header h2 a" ); if ( tTags.is( "a" ) ) { tTags.contents().unwrap(); } }); </script>
Now it removes both header text link and image link
March 16, 2017 at 9:48 pm #1777Tom
KeymasterThanks for sharing!
I’ll get a hard-coded option into the plugin ASAP 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.