Adding a link to the post from featured image

Community Forums Forums General Discussion Adding a link to the post from featured image

This topic is: resolved

This topic contains 1 reply, has 1 voice, and was last updated by  aaronsummers 1 year, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22916

    aaronsummers
    Participant
    Post count: 5

    I’ve moved the featured image above the title using this snippet

    remove_action(‘genesis_post_title’,'genesis_do_post_title’);
    remove_action(‘genesis_post_content’,'genesis_do_post_image’);
    remove_action(‘genesis_post_content’,'genesis_do_post_content’);

    add_action(‘genesis_before_post_title’,'child_post_image’);
    add_action(‘genesis_post_title’,'genesis_do_post_title’);
    add_action(‘genesis_post_content’,'the_content’);

    function child_post_image() {
    $large_image_url = genesis_get_image( array( ‘format’ = & > ‘url’, ‘size’ = & > ‘themes’));
    $img = genesis_get_image( array( ‘format’ = & > ‘html’, ‘size’ = & > ‘themes’, ‘attr’ = & > array( ‘class’ = & > ‘alignleft post-image’ ) ) );
    printf( ‘<a href="%s" title="%s">%s</a>’, $large_image_url, the_title_attribute(‘echo=0′), $img );
    }

    I tried replacing the first %s used for the href with this ' . get_permalink() . ' but that returns no image at all.

    Any help would be appreciated!

    #22935

    aaronsummers
    Participant
    Post count: 5

    Fixed it!

    printf( ‘<a href="’ . get_permalink() . ‘"><img src="%s" class="alignleft post-image" title="%s" alt="’ . get_the_title() . ‘"></a>’, $large_image_url, the_title_attribute(‘echo=0′));

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Adding a link to the post from featured image’ is closed to new replies.