0

I've been trying to get post format to work for a while now, and for some reasons it is still not working the way it should.

I am creating a custom theme based on HTML5 Blank theme.

First thing I did was to add post_formats to functions.php

function add_post_formats() {
add_theme_support( 'post-formats', array( 'gallery', 'quote', 'video', 'aside', 'image', 'link', 'audio' ) );}

Post formats are now called in wp-admin and I can see the box for choosing the post_format in "Add new post". I then added this code to my loop.php to set the post format to a specific post

<?php if (have_posts()): while (have_posts()) : the_post(); if(!get_post_format()) {
get_template_part('format', 'standard');
} else {
get_template_part('format', get_post_format());
} ?>

But something is still missing because each post has a format attached to it, but It does not change anything on the display. For example format-video or format-links looks exactly the same as a standard format. In other words, embedded videos (for ex.) are not displayed on my article home page even though the post format is set and the video url is embedded in the content.

I am missing something, or doing someting wrong, and I've been struggling with this for hours, even though I read the codex again and again. Could anyone tell me what am I doing wrong ?

  • 1
    Do you actually have different template parts implemented for different formats? – Rarst Nov 1 '15 at 14:59
  • Yes, and I managed to make it work thanks to someone's comment, but he deleted it. I had content-x for my templates but I called for format-x in my function. – dbsso Nov 1 '15 at 15:27
1

Post formats are not magic. Your theme needs to actually have a code to generate different HTML (or apply different CSS rules) for different format.

Having the theme "suuport" post formats is nice for future compatibility of the content, but by itself it doesn't do anything to how the content is displayed.

0

I just posted a very similar answer here:
https://wordpress.stackexchange.com/a/212261/37314

summarised here:

Mostly you would make CSS changes. For example, a post that has the aside format will have included in it's mark-up a class of format-aside which you could override in your own CSS, whether it be by way of child theme support or CSS plugin.

I've only just been playing with this today (incidentally, which is how I came across this question).

Example: You could hide the title of posts tagged with the quote post-format (ie format-quote) by including this in your CSS file:

.home .format-quote .entry-title {
    display: none;
}

This would then format that entry on your blog page / index to not include the title from the post, and would make the quote just appear as more of an inline quote between two posts.

here are two reference posts for you to have a look at:

WordPress Codex page on Post Formats
Elegant Themes Blog post: Creating Post Formats

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.