• Hi,

    I’m using Wp Show Posts (with GeneratePress and GPP) to show post sections of different categories in the frontpage.

    Let’s say I have an external-articles Category for which I want the image and title to link to an external URL (defined by an ACF custom field within the post).

    Is there a way to do it?

    I see there’s a filter for image href, is there a filter for post title also?

    Thanks.

    Álvaro

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tom

    (@edge22)

    There isn’t currently a filter for the URL.

    However, you can likely use this filter: https://codex.wordpress.org/Plugin_API/Filter_Reference/post_link

    Something like:

    add_filter( 'post_link', function( $link, $post ) {
        if ( 10 === $post->ID ) {
            $link = 'yourcustomurl.com';
        }
    
        return $link;
    }, 10, 2 );

    You’d need to update the 10 to the post ID, and the custom URL of course.

    Thread Starter Alvaro Gois dos Santos

    (@alvarogois)

    Thanks for your help Tom. A little too much for my poor skills I’m affraid.

    As an alternative, I looked through WPSP code to find a way to use this agentwp.com example for “hijacking” the title permalink with a custom field. Couldn’t figure it out either.

    As a last resource, I used a similar approach to this plugin’s: Redirect Post to URL, which uses wp_redirect. Not so elegant, doesn’t let you open the link in a new tab, but it works.

    Plugin Author Tom

    (@edge22)

    Glad you found something that worked 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom link for title and image’ is closed to new replies.