WordPress.org

Ready to get started?Download WordPress

Forums

generating a post that links to a page (1 post)

  1. mdunbavan
    Member
    Posted 2 years ago #

    Hi there. My name is Mark

    I am currently developing a site in WP. I have created post thumbnails and they work now on a specific page and link like I want them to see here. This is created with a post and the post has the featured image as the thumbnail that creates each one and some text in content that creates the title for each one.

    What I am struggling to achieve at the moment is how to get that post thumbnail to link to a page that contains images further for that wedding. I have put this code in the functions.php to make it link to the post permalink page;

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    
    	$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    
    	return $html;
    }

    This tells WP that this post is linked to the permalink it creates. but what I want is it to then link to a page that has the images further like this here

    I have got the template set up for this page that has advanced custom fields that call in the images that have been uploaded to the page itself as I have had to manually create the page to correspond with the permalink which I know is not native WP and this is where I am getting stuck with it. I just want the client to post the featured image to create the thumbnail and then in that post add the images via advanced custom fields that will then correspond with the main sliding gallery as per the link above. Is this possible or does it look like I have gone the wrong way about creating this. I know the logic is there but cannot seem to crack the basic function of this site.

    Help on this would be much appreciated.

    Regards

    Mark

Topic Closed

This topic has been closed to new replies.

About this Topic