Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Wie man automatisch Featured Images mit Posts in WordPress verknüpft

Hinweis der Redaktion: Wir erhalten eine Provision für Partnerlinks auf WPBeginner. Die Provisionen haben keinen Einfluss auf die Meinung oder Bewertung unserer Redakteure. Erfahre mehr über Redaktioneller Prozess.

Kürzlich fragte einer unserer Leser, ob es möglich sei, in WordPress automatisch Bilder mit Blogbeiträgen zu verknüpfen.

Die meisten WordPress-Themes verlinken standardmäßig Bilder mit Beiträgen, aber einige Themes tun dies nicht.

In diesem Artikel zeigen wir Ihnen, wie Sie automatisch Bilder mit Beiträgen in WordPress verknüpfen können.

Automatically link featured images to posts in WordPress

Warum sollte man Featured Images mit Posts in WordPress verlinken?

Da Bilder ansprechender sind als Text, kann die Verwendung von Featured Images dazu beitragen, das Engagement der Nutzer in Ihrem WordPress-Blog zu steigern.

In der Regel sind die Bilder groß und nehmen mehr Platz ein als der Text. Sie sind bunter und daher auffälliger. Außerdem lassen sie sich auf kleineren Geräten wie Handys und Tablets leichter anklicken.

List25 using featured images to engage users

Wenn die Miniaturansichten Ihrer Beiträge jedoch nicht anklickbar sind, wird es für die Nutzer schwieriger, Ihre Beiträge zu sehen.

Die meisten WordPress-Themes verlinken standardmäßig Bilder mit den Beiträgen.

Einige Themes verwenden diesen Ansatz jedoch nicht, was es für Sie schwierig macht, angezeigte Bilder richtig zu nutzen.

Sehen wir uns nun an, wie Sie automatisch Bilder mit Beiträgen in WordPress verknüpfen können.

Automatisches Verknüpfen von Featured Images mit Posts in WordPress

Bei dieser Methode müssen Sie Code zu Ihren WordPress-Dateien hinzufügen. Wenn Sie dies noch nicht getan haben, lesen Sie unseren Leitfaden für Einsteiger zum Einfügen von Snippets aus dem Internet in WordPress.

Sie können diesen Code in die Datei functions.php Ihres Themes einfügen. Eine bessere Möglichkeit, benutzerdefinierten Code in WordPress hinzuzufügen, ist die Verwendung eines Code-Snippets-Plugins.

function wpb_autolink_featured_images( $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;
}
add_filter( 'post_thumbnail_html', 'wpb_autolink_featured_images', 10, 3 );

Dieser Code fügt einfach einen Link um den generierten Code herum ein, um vorgestellte Bilder oder Post-Thumbnails auf Ihrer Website anzuzeigen.

Dieser Code fügt auch einen Link um vorgestellte Bilder auf Seiten mit einzelnen Beiträgen hinzu. Wenn Sie die Bilder eines einzelnen Beitrags nicht mit demselben Beitrag verknüpfen möchten, verwenden Sie diesen Code.

function wpb_autolink_featured_images( $html, $post_id, $post_image_id ) {

If (! is_singular()) { 

$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>';
return $html;

} else { 

return $html;

}

}
add_filter( 'post_thumbnail_html', 'wpb_autolink_featured_images', 10, 3 );

Wir empfehlen die Verwendung von WPCode, um benutzerdefinierten Code in WordPress hinzuzufügen.

WPCode WordPress code snippets plugin

WPCode ist das beste Code-Snippets-Plugin und wird von über 1 Million Websites verwendet. Es macht es einfach, Code-Snippets in WordPress hinzuzufügen, ohne die functions.php-Datei Ihres Themes zu bearbeiten.

Zunächst müssen Sie das kostenlose WPCode-Plugin installieren und aktivieren. Wenn Sie Hilfe benötigen, folgen Sie unserer Anleitung zur Installation eines WordPress-Plugins für eine Schritt-für-Schritt-Anleitung.

Sobald das Plugin aktiviert ist, gibt es einen neuen Menüpunkt mit der Bezeichnung „Code Snippets“ in Ihrer WordPress-Adminleiste.

Wenn Sie darauf klicken, wird eine Liste der auf Ihrer Website gespeicherten Codeschnipsel angezeigt. Da Sie das Plugin gerade erst installiert haben, ist Ihre Liste noch leer.

Um Ihr erstes Code-Snippet in WordPress hinzuzufügen, klicken Sie auf die Schaltfläche „Neu hinzufügen“.

Click the Add New Button to Add Your First Custom Code Snippet in WPCode

Als Nächstes wird die Seite „Snippet hinzufügen“ angezeigt.

Gehen Sie zur Option „Eigenen Code hinzufügen (neues Snippet)“ und klicken Sie auf die Schaltfläche „Snippet verwenden“.

Add your new custom code snippet in WPCode

Danach müssen Sie Ihrem Codefragment einen Namen geben. Das kann alles sein, was Ihnen hilft, sich an den Zweck des Codes zu erinnern.

Fügen Sie dann das oben kopierte Snippet in das Feld „Codevorschau“ ein. Vergessen Sie nicht, in der Dropdown-Liste auf der rechten Seite „PHP Snippet“ als Codetyp auszuwählen.

Paste code into WPCode to automatically link featured images to posts

Blättern Sie dann auf der Seite nach unten zum Abschnitt „Einfügen“.

Sie können es bei der Methode „Auto Insert“ belassen, so dass der Codeausschnitt automatisch an der richtigen Stelle eingefügt und ausgeführt wird.

Pick the insertion method for your custom code snippet

Zum Schluss schalten Sie den Schalter von „Inaktiv“ auf „Aktiv“ um.

Klicken Sie dann auf die Schaltfläche „Snippet speichern“.

Save and activate your custom code snippet

Das war’s. Jetzt werden Ihre vorgestellten Bilder automatisch mit Ihren Beiträgen verknüpft.

Wir hoffen, dass dieser Artikel Ihnen geholfen hat zu lernen, wie man automatisch Bilder mit Beiträgen in WordPress verknüpft. Vielleicht interessieren Sie sich auch für unsere Anleitung zum Hinzufügen von Bildunterschriften zu vorgestellten Bildern in WordPress oder unsere Liste der besten Webdesign-Software.

Wenn Ihnen dieser Artikel gefallen hat, dann abonnieren Sie bitte unseren YouTube-Kanal für WordPress-Videotutorials. Sie können uns auch auf Twitter und Facebook finden.

Offenlegung: Unsere Inhalte werden von unseren Lesern unterstützt. Das bedeutet, dass wir möglicherweise eine Provision verdienen, wenn Sie auf einige unserer Links klicken. Mehr dazu erfahren Sie unter Wie WPBeginner finanziert wird , warum das wichtig ist und wie Sie uns unterstützen können. Hier finden Sie unseren redaktionellen Prozess .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Das ultimative WordPress Toolkit

Erhalte KOSTENLOSEN Zugang zu unserem Toolkit - eine Sammlung von WordPress-bezogenen Produkten und Ressourcen, die jeder Profi haben sollte!

Reader Interactions

28 KommentareEine Antwort hinterlassen

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Nelson Nchopereu says

    How do I put my featured image such that if the post link on WhatsApp or Facebook is shared it goes with the featured image?
    Thanks

  3. Rohit Sharma says

    How does wpbeginner design its featured images and YouTube thumbnails?
    What tools / apps / software do you use?

    They look pretty awesome..

    I couldn’t find this on your website blueprint post..so I thought of asking here..

    Waiting for your reply..!

    • WPBeginner Support says

      Unless I hear otherwise, we use Camtasia for our videos and Photoshop or Affilinty designer for the article thumbnails :)

      Admin

  4. özkan says

    Hello,

    Im so jealous of all these people that says it works.

    It doesnt work for my site. Can anybody help me about this ?

    Thank you.

    • WPBeginner Support says

      You may want to reach out to your theme’s support to see if there is a theme specific setting that could be overriding this.

      Admin

  5. Carlos Alberto Romay says

    Hi there! Awesome article, I am need to do the opposite; to discover HOW TO avoid any link from image, title or text to any url, how can I do this? I mean, you reah my website, see the blog but you CAN´t click any image, text or title, is this possible? thanks

  6. Stuart Campbell says

    How can I use this method to have the featured image link to another url? What am I missing here? Thanks

  7. Sandeep says

    On my blog the featured images are not clickable.so it becomes a little difficult for the user to navigate to blogs.

    I think the theme whic i am using that doesn’t support that it.

    But the code you have mentioned above i will try it .
    i will try it , if it worked , that will great.

  8. Susan Howarth says

    Thank you so much for this!! I was worried this issue would take a lot of time and energy to figure out. After a quick copy and paste of your code, and it worked perfectly! :)

  9. modo seyoum says

    i’m looking for the best way to add links to a featured image. for instance– if you click on the link below, you’ll see the header image and then two links in the content region. i’d rather have those two links appear in the header in a way that doesn’t compromise any responsive design. i have a few ideas, but i’d like to hear from a different perspective…

  10. jeet sandhu says

    Hie, i have a different query. I tried displaying specific posts in specific pages using ‚post in page‘ plugin. But the featured images that i have set for posts doesn’t show on the page. I mean only the title of the post is showing, but I want the featured images of all the posts to be displayed, too! Can you suggest me any way or plugin that can help me achieve this. I have searched the entire web; no one has the answer. I would be grateful if you could help me.

  11. malik aadil says

    I am new blogger this article helped me a lot

    I was using links of in the images but the problem was Images are opening but not going to linked article

  12. Sulman Qamar says

    hey dear ,
    here isn’t concerning solely featured pictures however additionally concerning committal to writing . …
    in some model that’s operating.. most of your data is nice on behalf of me and my members ..
    we follow principally .:)
    in this richest article I actually have found totally different sort of data ..
    Hope you best for your blogging future :)
    ~salman qamar

  13. Dale Reardon says

    Hi,

    Thanks very much for this useful code.

    Is this a way (can I trouble you for the function code) to also add an ALT tag to the image link with the title of the post being linked to as the alt text?

    I’m vision impaired and at the moment the link just says the image filename which isn’t useful much of the time.

    Thanks,
    Dale.

  14. Ankit Agarwal says

    Thanks for his tutorial. I tried this on my blog but realized that the image being shown in the thumbnail is not my featured image but the first image I am using in the post. Probably because I am using MotoPress page builder plugin. and

    There seems to be a conflict between this code and the Motopress plugin.

  15. Dale Reardon - My Disability Matters says

    Hi,

    That worked fantastically.

    Only one further query – my website is all about disability issues:

    so I want things to be accessible and I’m blind myself so appreciate all sites doing their bit.

    Is there a way to assign ALT text to this image link composed of the title of the page it is linking to? At the moment my screen reader just reads out the picture file name which sometimes isn’t very helpful.

    Your help most appreciated.

    Dale.

Eine Antwort hinterlassen

Danke, dass du einen Kommentar hinterlassen möchtest. Bitte beachte, dass alle Kommentare nach unseren kommentarpolitik moderiert werden und deine E-Mail-Adresse NICHT veröffentlicht wird. Bitte verwende KEINE Schlüsselwörter im Namensfeld. Lass uns ein persönliches und sinnvolles Gespräch führen.