Remove links from Posts module

Hi there

I have a category of posts which are displayed using the Posts grid module and I want to disable the links on these posts (feature image and title on the grid) so visitors can see the grid info but they can’t click through the to actual post. They are all the same category. Happy adding php to my functions file as I’m using Genesis if there is a solution that requires that?

Thanks in advance.

Hey Nicola,

Thanks for getting in touch! This can be done via jQuery. The code below will disable all feature image and title links on a Post module using Grid layout site wide. If you want to target a specific module, you can place a class/ID on the module and add the selector respectively.

jQuery(document).ready(function($) {
  jQuery('.fl-post-grid-image a, .fl-post-grid-text h2 a').click(function(event) {
    event.preventDefault();
  });
});

Let us know if you need anything further!

Ben

Hi Ben,

Can you please elaborate on how to do this?

I am a complete novice to wp. I tried adding this code under Themes - Code - Javascript Code but it didn’t do the trick.

Thanks for the help!

Hi Ben,

Can you please elaborate on how to do this?

I am a complete novice to wp. I tried adding this code under Themes - Code - Javascript Code but it didn’t do the trick.

Thanks for the help!

Steve

Hey Steve,

That is exactly what needs to be done to make it work. Are you using the grid layout on the Posts module? Do you mind sharing the URL of the site so we can take a look?

Ben

Hi Ben,

Thanks for the quick response. I’m using the feed layout.

Here are two links for blog pages (I’m using one page for video posts and the other for written posts):

http://ouyangjianshen.com/?page_id=38
http://ouyangjianshen.com/?page_id=40

Thanks,
Steve

Hey Steve,

You can use this code instead. You can place it on the same spot.

jQuery(document).ready(function($) {
  jQuery('.fl-post-feed-title a, .fl-post-feed-image a').removeAttr('href');
});

Ben

That worked, thanks a lot.

One more question - Is there also a way to get the title of the post to not change color when the mouse hovers over it.

Thanks,
Steve

Hey Steve,

Actually, just use this instead so it doesn’t have that highlight stuff.

jQuery(document).ready(function() {
  jQuery('.fl-post-feed-title a, .fl-post-feed-image a').each(function() {
    jQuery(this).replaceWith(jQuery(this).contents());
  });
});

Ben

Thats perfect, thanks for the help, Ben.

No worries! Enjoy BB! :slight_smile:

Ben