Site logo

Archived topic

Link Post Format and Clickable Article

7 replies · Started by Marek on May 19, 2020

Viewing posts 1–8 of 8

Hey guys, congrats on 6 years!

I'm using this bit of code to make the entire .inside-article blog post containers clickable:

<script>
jQuery( document ).ready( function($) {
var body = $( 'body' );
if ( body.hasClass( 'blog' ) || body.hasClass( 'archive' ) ) {
$( '.type-post' ).on( 'click', function() {
var link = $( this ).find( '.entry-title a' ).attr( 'href' );
if ( link ) {
window.location = link;
}
} );
}
} );
</script>

This works great; however, when utilizing the Link Post Format, the container links to the actual link post and not the page that the link post links to.

Any ideas on how to get the clickable container to link to the linked post in the link post type rather than the post itself?

It works fine if I click on the title of the link post type as it normally does.

I hope that wasn't too confusing!

Thanks!

Hi there,

can you link us to your site so we can take a look?

Hey David,

The site is incomplete but I just uploaded it to a temporary server and linked it in the post.

If you look at the homepage you will see a post titled "Link Test Page." It is a Link Post format so when clicked it should take the user to the first link on that post.

The entire container is clickable but different spots link to different pages. Clicking the image takes the user to one page, and clicking the title or empty space will take the user elsewhere.

My goal is to have users click anywhere on the container and land on the page that is linked, and not the actual Link format post itself.

The clickable containers work great elsewhere, but it gets a little wonky with the link post format.

Thanks!

Instead of the jQuery - try this CSS method:

.generate-columns .inside-article {
    position: relative;
}

.generate-columns .inside-article .entry-header a:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

Thanks for the quick reply!

That works well and all the links are consistent now, but the link post still doesn't take me to the desired page.

It takes me to the actual link post instead of the post that it should be redirected to (About Page).

Thanks :)

How are you adding the link URL to the post ?
As that should happen by default

Hey David,

I'm a goof, it was still linking to the localhost URL when I sent it over to you. That did work.

Thanks!

Glad to hear that :)

This archived topic is closed to new replies.