Treehouse: Grow your CSS skills. Land your dream job.

Display content from another page with custom fields in WordPress

  • # May 24, 2012 at 2:03 pm

    So, I am trying to hack my way through this and I almost have a solution, but I feel that I am either missing some steps or going about it the wrong way. Either way here’s what I am trying to do.

    In WordPress, I am trying to get content from certain pages that are using custom fields to insert editable blocks of content (MultiEdit Plugin). I have one page setup to call back these pages using the query_post function.
    I have it setup to filter out the pages by a custom field which works, but it’s not pulling the other custom fields into the content area.

    Here’s my code:

    < ?php

    $args = array(
    'post_type' => 'page',
    'meta_value' => 'inventory'
    query_posts( $args ); ?>

    So, from my understanding the above pulls the content from the pages that have the custom field of inventory. But is there something else that I need to include so that it pulls the other content that is in the other custom fields within those pages?

    Any help is greatly appreciated. Thanks!

    # May 28, 2012 at 1:09 pm

    I think what you are looking for is.
    <?php echo get_post_meta($post->ID, ‘name_of_custom_meta’, true); ?>

    This will output the saved info in the custom meta box.

    Check the WordPess Codex for get_post_meta() for more details.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.