• Resolved eightfold

    (@eightfold)


    I’ve done tumblelog-like themes earlier using custom fields for everything from quote source to link URLs and I was really happy when I saw the news about post formats UI coming in 3.6.

    I’ve been trying to build a theme using the latest alpha version, but I don’t understand if doing what I did with custom fields manually (or with Advanced Custom Fields or Post Formats Admin UI) will be possible with the post formats feature in 3.6. It seems data comes preformated, gets injected into HTML elements and that I can only use the_content to output them to the post. And as it seems right now (I know this feature isn’t stable yet), the link post type doesn’t even get a CSS class for the <p> surrounding the link itself. What if I’d like to put the link in an <h2> instead of the <p>, like I could with custom fields and get_post_meta, is it possible?

    Also, I ponder why a format like quote has an option for “Title” as it is superfluous. That will force most people to manually put in some bogus data in the title field and seems like a makeshift solution. I see WordPress needs a title, but it seems to me that it would be better to handle this like Post Formats Admin UI does, ie the title for the post is set using the first 50 characters of the content automatically.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Dominik Schilling

    (@ocean90)

    WordPress Core Developer

    You can use <?php the_post_format_{type}; ?> where {type} can be video, audio, image, url or chat.

    To add on to Dominik’s suggestion, there’s also get_post_format_meta( $post_id ) if you’re trying to grab a particular field rather than the formatted post. get_post_format_meta() returns the array

    array(
    	'quote'        => '',
    	'quote_source' => '',
    	'url'          => '',
    	'image'        => '',
    	'gallery'      => '',
    	'audio'        => '',
    	'video'        => '',
    );

    Thread Starter eightfold

    (@eightfold)

    To add on to Dominik’s suggestion, there’s also get_post_format_meta( $post_id ) if you’re trying to grab a particular field rather than the formatted post. get_post_format_meta() returns the array

    Thanks, nice to see it is possible! It seems this is where structured-post-formats in functions.php actually gets useful too.

    Sorry for the stupidity but I’m not sure I understand how to output the data looking at what you gave me though.
    <?php the_post_format_url(); ?> outputs what I want for the Link URL of the link and quote post format, but how I’m not sure how I should format the php tag for the other fields like quote and quote_source. <?php the_post_format_quote(); ?> does not work and I don’t understand the role of $post_id in your example.

    Thanks again!

    Thread Starter eightfold

    (@eightfold)

    OK, I’m still looking for how to output quote and quote_source. I’ve been searching the file contents of the WP source code for hints, but have not managed to find anything. For others who run into the same problem my interim solution is to use add_theme_support( 'structured-post-formats' for everything but the quote format, for which i use add_theme_support( 'post-formats' and let WP generate the code. The code that is output follows the reasoning of this post, which I think is semantically fine.

    But, for anyone who might have an answer to my original question — how to output quote & quote_source — I’m still very eager to know.

    hello,

    Your question got me on track, so thanks ??

    get_post_format_meta returns an array, with the post meta values for the keys listed above – e.g.

    $pm = get_post_format_meta(get_the_ID());

    $thequote = $pm[‘quote’];
    $thequotesource = $pm[‘quote_source’];
    $thequoteurl = $pm[‘url’];

    (or did I misunderstand? ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to output 3.6 post format UI fields to where I want?’ is closed to new replies.