• Is it possible to have the first image in the post (the one before the MORE tag) link to the full post, just like the post title or the ‘Read more’ link do? I know I can wrap the image in link tags once posted, but this way it remains a link even after opening the full version of the post, whereas the post title is no longer clickable.

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Within your wordpress active theme, you have 2 files: one is called index.php, the other one is called single.php.

    The single.php controls the look of the page after you clicked on image. If you don’t have this file, just duplicate index.php and rename it to single.php.

    In single.php, image shouldn’t be wrapped by any link.

    Thread Starter white_pawn

    (@white_pawn)

    Yes, I’m aware of this. However, single.php retrieves the post content via the_content(). That means I’d have to store the post content in a variable, then parse it and get rid of the link tags. I was hoping for a built-in/ready-made solution. ??

    Indeed, you can create that with custom fields.

    try: custom field template

    With this you create the upload function for the image, echo the variable in both index.php and single.php, except that the variable from index.php needs to link to the post, while the same variable from single.php you don’t wrap it in link tags.

    Thread Starter white_pawn

    (@white_pawn)

    Thanks fldtrace.
    I did it the ugly way. This way at least it affects everything I ever posted. Just in case someone needs this, simply replace the_content() in your index.php with the following:

    $content = get_the_content('MORE »');
    $separator1 = "<img";
    $separator2 = "/>";
    $content = preg_split("#$separator1#",$content);
    $before = $content[0].'<a href="'.get_permalink().'"><img ';
    $after = preg_split("#$separator2#",$content[1]);
    $after = $after[0].'/></a>'.$after[1];
    $content = '<p>'.$before.$after.'</p>';
    echo $content;

    The effect can be seen here: minimalismi.com
    I’m not sure if it will affect the performance. If anyone knows of a more efficient way to do it, please let everyone know. Thanks.

    is there a way to get this to work with the seemore and sliding read more plugins? it looks great on your site, but when i implement it with those plugins, it breaks. also, it would be awesome if i could get it to stay on the index instead of jumping to the permalink. finally, when i click on the image again, i get a broken link (instead of “less” or “back). let me know if you have any thoughts. thanks!

    site in progress: https://metafold.net/glow

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Lead image as ‘more’ tag or post title link’ is closed to new replies.