[Resolved] custom link or none?

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support custom link or none?

This topic contains 9 replies, has 3 voices, and was last updated by  Tom 2 years, 5 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1293

    dasigna
    Participant

    hi 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.

    #1294

    Tom
    Keymaster

    There’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 🙂

    #1295

    dasigna
    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.

    #1296

    dasigna
    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?

    #1304

    Tom
    Keymaster

    You 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;
    }
    #1306

    dasigna
    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!

    #1312

    Tom
    Keymaster

    Awesome, glad I was able to help!

    Merry Christmas to you and your family as well 🙂

    #1490

    Alexander Seboe
    Participant

    Another 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>
    #1760

    Alexander 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

    #1777

    Tom
    Keymaster

    Thanks for sharing!

    I’ll get a hard-coded option into the plugin ASAP 🙂

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.