Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I know that this is such a basic question but I have very little Wordpress experience and was hoping I could get some help.

I have a plugin that creates Custom Post Types and Custom Fields. It does both of these things easily, but provides zero support, not even a forum. I created a meta box (meets_on) with three fields.

The first field I created is a multi-check box with day of the week options (called day) and options Sunday, Monday, Tuesday, etc.

The second field I created is a multi-check box with location options (called location) and lists all the options for cities.

The third field I created is a multi-check box with age range options (called age_range) and lists all the options for age range (18-24, 25-30, etc.)

I absolutely cannot figure out how in the world to get these fields to display either on a single post or in the archive loop. I've tried the Wordpress codex suggestions and other answers but nothing is working. Simply nothing displays. I've used get_post_meta, etc.

I just simply need a post to display what I've selected in the back-end; i.e., this group meets on Fridays, in Akron, with an age range of 18-24. From the admin panel, everything is perfect - but I can't get it to display the selections I've made as admin in a single post or category view.

I know this is a long post, but thanks so much for ANY help. I've spent hours trying to figure this out on my own.

Ashley

EDIT:

Here is my code from content.php. My theme basically has a bunch of if:else statements about what kind of entry it is: if is_page, if is_archive, id is_single and this is what I put in if is_single :

<div class="entry-content">
    <?php cyberchimps_featured_image(); ?>
        <?php the_content( __( 'Continue reading', 'cyberchimps' ) . ' <span class="meta-nav">&rarr;</span>' ); ?>
                        <?php $meta_data = get_post_meta($postid,'meets_on');
// var_dump($meta_data); // debugging
echo $meta_data['day']; ?>
        <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'cyberchimps' ), 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->

EDIT 2:

        <?php $postid = get_the_ID(); ?> 
     <?php 
     $meta_data = get_post_meta($postid,'meets_on');
// var_dump($meta_data); // debugging
echo $meta_data['day']; ?>

EDIT 3: This code solved the issue:

<?php
$meets_on = get_post_meta( $post->ID, 'meets_on', true ); 
foreach( $meets_on as $meet){
echo $meet['day'];
} ?>
share|improve this question
    
Can you provide the name of the plugin you are using? –  Rachel Baker Aug 9 '13 at 14:03
    
Yes, its WCK Custom Fields Creator –  Ashley P. Aug 9 '13 at 14:23

1 Answer 1

echo get_post_meta($postid,'meta_key_name',true); is what you want if the plugin is storing data as individual keys in the post meta table. You may be dealing with an array of values though which would require something like:

$meta_data = get_post_meta($postid,'meta_key_name');
// var_dump($meta_data); // debugging
echo $meta_data['some_key'];
echo $meta_data['another_key'];

As you don't even name the plugin or provide a link to it (that I can see) it is hard to say more. The plugin may not even be saving data to post meta. I could be saving to the options table or to a table of its own creation.

Reference:

http://codex.wordpress.org/Function_Reference/get_post_meta

share|improve this answer
    
This is somewhat how the plugin documentation told me, but it doesn't work - and I know its because I'm implementing it wrong: cozmoslabs.com/wordpress-creation-kit/custom-fields-creator –  Ashley P. Aug 9 '13 at 13:32
    
What confuses me most is 1) where to put this code and 2) do I need to put in this array that they've given as an example? I'm sorry if these are basic questions, I have very little wordpress experience. –  Ashley P. Aug 9 '13 at 13:33
    
I tried it with just one key first - 'day'. –  Ashley P. Aug 9 '13 at 14:07
    
Nothing returns. The post doesn't return any errors, but it doesn't show the field result, either. Just blank. –  Ashley P. Aug 9 '13 at 14:47
    
Is $postid set? I used a made up variable as your original post had no code. You actually have to use the correct post ID. –  s_ha_dum Aug 9 '13 at 14:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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