Jayj.dk

Menu

Skip to content
  • Blog
  • WordPress
  • Themes
  • Plugins
You are here: Home / WordPress / Link thumbnail til indlæg
By Jesper Johansen

Link thumbnail til indlæg

Please note: This is an old post. The information is probably not accurate and up-to-date anymore.

Hvis du bruger WordPress’ 2.9 thumbnail feature, vil din thumbnail som standard ikke linke til dit indlæg. Hvis du vil have den til at gøre det, skal du tilføje dette til dit temas functions.php

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_the_title( $post_id ) ) . '">' . $html . '</a>';

     return $html;
}

Overstående kode er taget fra Justin Tadlocks indlæg “Everything you need to know about WordPress 2.9′s post image feature”, hvor du kan læse meget mere om hvordan du kommer til at bruge thumbnail funktionen.

Hvis du ikke ønsker at den skal linke til indlægget på selve indlægssiden, kan du tilføje if ( !is_single() )

if ( !is_single() )
    $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>';
Posted in WordPress on October 9, 2010

Related Posts

  • Youtube Profile Field 3.1
  • Grid Columns Media Button WordPress plugin
  • Multiple Select Lists in the Theme Customizer
  • Youtube Profile Field updated to version 2.2

Post navigation

← Previous Post
Next Post →

Popular Posts

  • A free HTML5 and CSS3 theme
  • HTML5 Theme Updated to Version 2.0
  • Create a custom “Download” post type using WordPress
  • Cakifo, a Free WordPress theme
  • Japibas – Free Premium WordPress Theme
  • Multiple Select Lists in the Theme Customizer

Categories

  • WordPress
  • Updates
  • News
  • Web
  • Themes
  • Uncategorized

You can also find me on:

Powered by WordPress and Hybrid Core.

  • Twitter
  • Github
  • WordPress.org
  • LinkedIn