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

Was, warum und wie man die Beitragsformate in WordPress 3.1 anwendet

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.

Beitragsformate sind eine der aufregenden Funktionen, die in WordPress 3.1 eingeführt werden. Aber die meisten Anfänger haben keine Ahnung, was Beitragsformate sind, warum sie für Sie wichtig sind und wie Sie die Vorteile dieser großartigen Funktion nutzen können. Nachdem wir die Alpha-Version von WordPress 3.1 getestet haben, haben wir uns entschlossen, das Was, Warum und Wie der Beitragsformate zu erklären, die in WordPress 3.1 enthalten sind.

Was sind Beitragsformate?

Beitragsformate sind Metainformationen, die von Themes verwendet werden können, um die Darstellung eines Beitrags anzupassen. Ok, in einfachem Englisch sind Beitragsformate eine Methode, um einen bestimmten Beitrag zu stylen. Mit dieser Funktion können Sie das „Format“ der Anzeige eines bestimmten Beitrags festlegen. Diese Funktion erweitert den Micro-Blogging-Aspekt von WordPress, denn jetzt können Sie Videos, Links, Bilder, Audios, Zitate, Statusmeldungen usw. an einem Ort veröffentlichen, und das Beste daran ist, dass sie entsprechend gestylt werden.

Beispiele für die Verwendung

Werfen wir einen Blick auf den offiziellen Blog von Digging into WordPress. Dort gibt es zwei Arten von Beiträgen auf der Homepage. Der eine ist ein kompletter Beitrag, der einen Auszug anzeigt, wie in jedem anderen Blog auch. Interessant ist jedoch, dass sie eine spezielle Art von Beiträgen haben, die externe Links zu anderen Blogbeiträgen sind, die sie für ihre Leser nützlich finden.

Digging into WordPress Example Usage of Post Formats

Beim Bloggen geht es vor allem darum, Ressourcen zu teilen, und oft möchte ein Blogger einfach auf eine externe Ressource verlinken, weil er sie für seine LeserInnen nützlich findet. Das Hauptproblem dabei ist, dass sie einen neuen Beitrag verfassen müssen, um den Lesern mitzuteilen, dass sie auf eine andere Website gehen sollen. Das verwirrt den Endnutzer, weil er nicht weiß, um welche Art von Beitrag es sich handelt. Oft muss der Benutzer auf die Vollansicht des Beitrags klicken, nur um herauszufinden, dass der Autor möchte, dass er einen externen Link anzeigt. Auch wenn es Tricks wie diesen gibt, mit dem man aus Beitragstiteln heraus auf externe Links verweisen kann, wird dieses Problem des Beitragsformats alles lösen. Themendesigner können die „Linkformate“ so gestalten, dass sie auf eine andere Art und Weise angezeigt werden, wie es Jeff Starr für Digging into WordPress getan hat.

Die Macht dieser Funktion ist unbeschreiblich. Denn jetzt kann man kurze Statusmeldungen wie bei Twitter schreiben und sie anders gestalten, ohne viel Arbeit zu machen. Wenn Sie ein Zitat gefunden haben, das Ihnen gefällt, können Sie es teilen und mit einem Klick hervorstechen lassen. Unterm Strich wird WordPress durch die Funktion „Beitragsformate“ zu einer umfassenderen Blogging-Plattform.

Warum sollten Sie Beitragsformate verwenden?

Beitragsformate ersetzen die Notwendigkeit, Kategorien zu verwenden, um ähnliche Styling-Funktionen zu erreichen. Bisher haben die Entwickler die WordPress-Kategorien gehackt, um diesen Effekt zu erzielen, was zu einer Menge Unordnung und Verwirrung für neue Blogger führt. Durch die Verwendung von Beitragsformaten wird nicht nur die Unübersichtlichkeit in Bezug auf Kategorien verringert, sondern Ihr Blog wird auch zwischen Themes, die diese Formate unterstützen, portabel.

Außerdem wird Ihr Blog dadurch für Ihre Leser benutzerfreundlicher, da sie genau wissen, welche Art von Beitrag sie gerade sehen. Außerdem wird Ihr Blog dadurch lebendiger, weil Sie auf Ihrer Blogseite verschiedene Arten von Beiträgen haben. Zurzeit sehen die meisten Blogbeiträge sehr langweilig aus, weil alle Beiträge gleich aussehen. Die Beitragsformate werden eine dringend benötigte Lücke in den von WordPress betriebenen Websites füllen.

Wie man in WordPress 3.1 Beitragsformate hinzufügt und verwendet

Genau wie Beitragsminiaturen, Menüs, benutzerdefinierte Hintergründe und benutzerdefinierte Kopfzeilen werden auch die Beitragsformate eine themenaktivierte Funktion sein. Das bedeutet, dass diese Funktion nur verfügbar ist, wenn Ihr Theme kompatibel ist.

Achtung! Sie müssen ein gewisses Verständnis von HTML, CSS und den Funktionen der WordPress-Schleife haben, um diesem Tutorial folgen zu können.

Um „Beitragsformate“ in WordPress 3.1 zu aktivieren, müssen Sie die Datei functions.php Ihres Themes öffnen und den folgenden Code einfügen:

add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );

Hinweis: Beiseite, und Galerie sind nicht die einzigen verfügbaren Beitragsformate. Die verfügbare Liste der Beitragsformate sind:

  • beiseite – Typischerweise ohne Titel gestaltet. Ähnlich wie ein Facebook-Status-Update.
  • chat – Eine Chatmitschrift.
  • Galerie – Eine Galerie mit Bildern.
  • link – Ein Link zu einer anderen Seite.
  • Bild – Ein einzelnes Bild.
  • Zitat – Ein Zitat.
  • status – Ein kurzes Status-Update, normalerweise auf 140 Zeichen begrenzt. Ähnlich wie ein Twitter-Status-Update.
  • video – Ein einzelnes Video.

Eine vollständige Liste der Beitragsformate finden Sie im WordPress Codex.

Sobald Sie diesen Code hinzugefügt haben, sehen Sie ein neues Feld in Ihrem Beitrag schreiben Panel in der rechten Spalte, wo Sie veröffentlichen sehen.

Post Format Option in Post Write Panel

Wenn Sie den Beitrag geschrieben haben, können Sie das Format ändern und auf „Veröffentlichen“ klicken. So können Sie Ihren Beitrag in einem vorgestalteten Format anzeigen.

Aber halt, wir haben diese vorgestylten Beitragsformate noch nirgends in unserem Thema festgelegt. Selbst wenn Sie das Format in Ihrem WordPress-Beitragspanel auswählen, wird es keinen Unterschied machen, weil Ihr Theme nicht weiß, wie es angezeigt werden soll. Zu diesem Zweck müssen wir unsere Beitragsschleife bearbeiten.

Wir werden den bedingten Tag verwenden: has_post_format()

if ( has_post_format( 'aside' )) {
  // code to display the aside format post here
} else if (has_post_format('gallery')) {
   // stuff to display the gallery format post here
} else if (has_post_format('link')) {
   // stuff to display the link format post here
}else {
   // code to display the normal format post here
}

Worauf warten Sie noch? Bereiten Sie sich auf diese großartige Funktion vor. Wir können uns nur vorstellen, dass WordPress mit neuen Themes, die diese Funktion nutzen werden, mehr und mehr als Microblogging-Plattform genutzt wird.

Weitere Lektüre:

WordPress Codex Beitragsformate
Beitragstypen und Formate und Taxonomien, oh je!
Beitragsformate vs. benutzerdefinierte Beitragstypen

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 .

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

24 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. Rahul says

    if ( has_post_format( ‚aside‘ )) {
    // code to display the aside format post here
    } else if (has_post_format(‚gallery‘)) {
    // stuff to display the gallery format post here
    } else if (has_post_format(‚link‘)) {
    // stuff to display the link format post here
    }else {
    // code to display the normal format post here
    }
    Where do we have to add this code. Thanks in advance . Inside Index.php or somewhere else.

  3. Keely says

    Where exactly is this chuck of code added?
    I can’t find a thing about this anywhere; not being a php programmer I don’t know where to put it.

  4. Dave says

    It looks like your code is missing a closing bracket in the first line. It currently reads:

    if ( has_post_format( ‚aside‘ ) {

    but it should be:

    if ( has_post_format( ‚aside‘ )) {

    Great tutorial as always.

  5. Tom says

    So, OK I am still a little confused about a few concepts here…can somebody please help me out? I apologize in advance for the crazy length of this post but I am new to WP ;)

    I understand the concept of posts, pages, categories and tags – that’s easy.

    As I now understand, the new feature of „post formats“ (WP v3.1) relates to the styling of a „post“ (think: „blog post“), whereas the concept of „post types“ really means one of the five default WP „content types“ (post, page, attachment, revisions, nav menus – see (http://codex.wordpress.org/Post_Types).
    Likewise, the new feature of „custom post types“ (WP v3.0) relates to creating *new* „post types“ (outside of posts, pages, etc.), what ever that might be.

    WOW…that sounds understandable in…t h e o r y.

    OK, I DO get the new „post format“ in theory…but I am a visual type of learner, so I wanted to see what they could look like.

    So your example of the ‚link‘ „post format“ post at Digwp.com was good, but I also checked out some other themes, like: http://demo.themify.me/#theme=wumblr
    (side note here: confusing! – see how they refer to post formats as exactly that here: http://themify.me/themes/wumblr > Features… but at the top of that same page they call them „post types“).

    Anyhow…before I get to the „post types“ feature of WP, I have a few questions about the „post formats“ feature:

    1. Let’s say I want to make use of new „post formats“ in an existing theme; I add these 10 different post formats in WP and specify them in the theme (as per your instructions). But then what..? How does the actual *DESIGN* for each of those post formats come about on the site?
    Is it likely that most theme developers (mostly for the paid-for ones) will update their themes (the coding part, plus the actual design of the „post format“ part) – or should users wait for new themes to hit the market that offer this for the first time?

    What about theme frameworks – do we know of any that already offer child themes with the post formats feature incorporated? Some theme frameworks allow you to create (or radically customize) your own child themes based on a basic version, with not much or no coding involved…do we know if any providers have this level of customization already implemented?

    2. When I look at some of the themes that already use „post formats“ (see: http://themify.me/demo/#theme=wumblr) – what I notice is that *some* of the category names of the individual post formats match the names in the list of standardized formats (see: http://codex.wordpress.org/Post_Formats#Supported_Formats) – but some don’t! The following names that the Wumblr theme uses are not on that list: ‚general‘ and ’notes‘- while ‚aside‘ and ‚gallery‘ are on the list but not chosen category names for any of Wumblr’s new format type posts. So this leads me to ask…

    Compared to the usual practice of freely choosing names for categories (often for SEO purposes), what are the rules for naming categories for „post format“ posts? Do they HAVE to match the names on the list of standard „post formats“? If not, how would that change the code you suggested in your article, following where you say: „We are going to be utilizing the conditional tag: has_post_format() …“? If you DID use names in that code that differ from the standardized list, would that not go against the rule of standardization and make it difficult to switch themes?

    I also wonder if by categorizing „post format“ type posts by choosing names like: ‚link‘ or ’status‘ or ‚quote‘ for instance…how can anyone expect people to actively CHOOSE to click categories with THESE names, rather than posts that typically carry category names *describing their content*!!????

    With ‚video‘ and ‚image‘ and ‚gallery‘ … I could still understand that people might actively and out of curiosity click those to be shown a list of all the posts with that type of content, but link, status, quote….?

    ~~So does anyone understand how all of this works?~~

    So I make it VERY short with my question on „POST TYPES“ or more precisely „custom post types“:

    Where do THEY fit in here? I understand they are NOT the „blog post“ type posts we are talking…but „custom“ (=any type of content type BUT a post).

    ARE there already any themes having them implemented, and if so, can someone point me to some examples?
    ARE they handled by the theme or by a plugin?

    Thanks for your replies!!

    Tom ;)

    • Editorial Staff says

      Hey Tom,

      Lets take a stab at your long question, one by one.

      Wumblr Theme by Themify was released before WordPress 3.1 (so note, they did not have Post Formats at that time). So they called them whatever they liked, in this case post types“. Which again is a conflicting vocabulary, we recommend that it should be called Content Types because the whole idea of post types is to be NOT posts, RIGHT? Anyways so I think you are confused because of the semantics that Wumblr used. Again you mentioned later on why Wumblr has its own custom post formats rather than the supported formats. Because it was released before Post Formats were available, so they went with what they thought should be good.

      You would have to specify in your theme’s CSS that if a post format „XXX“ is called then add these styles. A good way to do this would be getting the themes that already support Post Formats and look how they do it. Or simply open your browser’s Source and you will see the default class that is added. Most frameworks will be compatible with Post Formats in their coming versions however not all child themes will be compatible. It is very likely that some theme developers may go back and add post formats to their old themes. But we can’t say for sure which ones will do that and which ones won’t. There are a lot of new themes that are already hitting the market. Woo Themes has some, Themify has some. StudioPress will be releasing their own very soon as well. So it is really up to you if you want to wait or not.

      Your category name does not have to match post formats. Post Formats, and categories are two separate taxonomies. You are free to name your category whatever you like.

      Custom Post (Content) Types and Custom Post Formats are two separate beasts. One is a custom taxonomy while other is a custom content type. They serve two separate purposes. Taxonomies are to make organizing and display of content types easier. Custom Post Formats are taxonomies and Post is a content type.

      Both Custom Post Types and Post Formats are handled by themes. However for Custom Post Types there are plugins that make your life easier. You can refer to our article about custom post types on this site that will show you the plugins.

      Admin

    • Editorial Staff says

      That page in the codex explains it all. It shows that they are adding this meta box to the custom content type „post“ and „pages“… They are adding the input fields, and they are saving it. Use that information, and build on top of it.

      Admin

  6. Bjorn van der Neut says

    So if I understand correctly its a little bit the same as copy the page.php to gallery.php modify it and in the page select as template „Gallery“.

    Only now its going to be not on page level but on post level?

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.