WordPress: How to pass additional Content to the blog-preview page?

For each blog-post on my wordpress-blog I’d like to have Teaxtarea where i can pass additional content for that post.

In my case that would be an unordered list which contains a quick overview of the content.

Read More

That additional content should be displayed in the preview of the post on the blog-preview-page.

My problem:

I am actually not sure on how to best add this additional content and then pass it to the preview.

Do I use wordpress’ custom fields for something like this?

I’m gratefull for a push in the right direction.

Thank you,
Nils

Related posts

Leave a Reply

3 comments

  1. If I understand you right, I’d take a look at “custom meta boxes” functionality – it allows you to add any type of additional input into your blog post admin area, and than display its content on front-end however you like.

    There’s a nice tutorial series on that topic, with example code snippets:
    http://wp.tutsplus.com/series/reusable-custom-meta-boxes/

    And if you’d like to display the textarea content only in preview mode, you can use appropriate conditional tag in you template file:
    http://codex.wordpress.org/Conditional_Tags#A_Preview

  2. The conditional tag is_preview returns true when a single post is viewed in Draft mode. The following will append post meta to the content when a post is being previewed:

    function so16799607_preview( $content )
    {
        if ( ! is_preview() )
            return $content;
    
        return $content . get_post_meta( get_the_ID(), 'my_post_meta', true );
    }
    add_filter( 'the_content', 'so16799607_preview', 10, 1 );
    
  3. You should check out Advanced Custom Fields. That’s a really stable plugin that lets you create custom meta boxes in posts, pages and custom post types. That plugin does exactly what your question states. Need al little PHP to get stuff from your database, but that is as easy as:

    <?php the_field(field_name);?>
    

    And the documentation is pretty good. And if you don’t like a plugin, it exports the PHP as well.

    Anther tool that does the same is Pods Framework. Both powerfull extensions to any WP install in my opinion.

    Hope this helps.