Problem with linking featured image on homepage featured posts

Hello, thanks for a great theme and the help you’ve already given on this topic.

I’ve followed along and added the custom JavaScript and CSS to turn the featured images on the five homepage featured posts into links.

It’s working great on my four smaller-sized images. But on the largest image in the center, the image links to www.nicolemperez.com/undefined which takes me to a page that says the URL can’t be found.

The headline link that’s on top of the image works fine, as does the category link.

Here’s the custom JavaScript I am running:

    ;(function($) {
        "use strict";

        if( $('.athemes_featured_posts_type_a').length ){

            $('.athemes_featured_posts_type_a .featured-item').each(function(){
              var link = $(this).find('a.post-title-standard').attr('href');
              $(this).prepend('<a href="'+link+'"></a>');
            });  
          
        }  

    })(jQuery)

And here’s the custom CSS:

    .sticky-inner > a {
      position: relative;
      display: block;
      z-index: 2;
    }

    .athemes_featured_posts_type_a .sticky-post > a {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 2;
    }

I can’t figure out what’s going wrong. I have link redirects set up on all five featured posts, but I can’t imagine that’s causing the problem since the other four are working.

On a related note, is there an easy way to make the category tags on those featured images not clickable?

Thanks for your help!

Hello there,

Please try this code:

    ;(function($) {
        "use strict";

        if( $('.athemes_featured_posts_type_a').length ){

            $('.athemes_featured_posts_type_a .featured-item').each(function(){
              var link = $(this).find('a[class^="post-title-"]').attr('href');
              $(this).prepend('<a href="'+link+'"></a>');
            });

        }

    })(jQuery) 

Let me know how it goes.

Regards,
Kharis

It worked! Thank you so much.

Is it also possible to un-link the category tags on those featured homepage posts? I would like them to not be clickable.

Hello there,

To accomplish it, try adding this jQuery code:

    ;(function($) {
       "use strict";

       if( $('.athemes_featured_posts_type_a').length ){

           $('.athemes_featured_posts_type_a .featured-item').each(function(){
             var catLink = $(this).find('.this-contents').find('.ispan > a');
             catLink.attr('href', '#').bind('click', function(e){
               e.preventDefault();
             }).css('cursor', 'default');
           });

       }

    })(jQuery) 

Regards,
Kharis

Success! Thank you so much for the help :slight_smile:

You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis