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've read a ton of tutorials and articles and searched for days now, but I still can't seem to get my custom fields to display in the loop and I could use a hand.

First off, I definitely have the custom fields enabled and they are taking data. When I edit a post (I'm using the More Fields plugin), I can see the native custom fields boxes on the post, and the data is loading from the database.

I am creating a child theme for Twenty Eleven, which is otherwise working beautifully. When I try to insert the

<?php echo get_post_meta($post->ID, 'details', true); ?> 

code into the loop, i get no response. I'm putting it on the index.php template. 'details' is the name of the custom field key I'm trying to display.

Right now, the pertinent bit of code I'm using is this:

<?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'content', get_post_format() ); ?>
                <?php echo get_post_meta($post->ID, 'start_time', true); ?>
            <?php endwhile; ?>

Alas, the data is not showing up on the front end. Does anyone have any idea why this isn't working? It seems like such a simple thing and I am a bit confused as to why the Twenty Eleven theme doesn't have something built in to handle custom fields.

I can post other bits of code or whatever if it's needed for further troubleshooting. Thanks in advance!

Just a follow up: I tried putting a basic

<p><?php echo "this is working" ?></p>   

inside the loop and that didn't work either. something is definitely screwy here. i've got the index.php inside the child theme folder, and the posts are definitely posting and displaying on the page. and that bit of code works perfectly if i put it inside the footer.

In case it would help, here's the link to my dev version: http://sandbox.littleoracle.net/starseed/?p=291

share|improve this question
    
inside your loop do: <?php var_dump(get_post_custom()); ?> this will show you all custom fields that are set for that post. If you can post your results here to better aid us. –  Brady Aug 2 '11 at 16:43
    
Weird. Just tried pasting that in and it didn't return anything. Nothing printing to the front end except the usual title and content. It is supposed to go inside the loop on the index.php template, right? –  jennifer Aug 2 '11 at 17:10
    
You've definitely activated your child theme? It's showing up in your theme choices? –  Aris Blevins Aug 2 '11 at 17:41
    
Yes, most definitely. It's working quite nicely. I've been able to do everything else I need on this, created and displaying custom post types, and all other kinds of things. The rest of the theme, minus IE testing, is working perfectly. The link is here: sandbox.littleoracle.net/starseed/?p=291 –  jennifer Aug 2 '11 at 17:59

2 Answers 2

Just passing on my solution in case it's of any help to anyone.

I'm still not completely sure what happened, but after disabling all plugins and eventually trying a completely separate, vanilla install on my localhost, I determined that something had gone wrong in the theme files.

I was able to fix the issues by downloading a fresh copy of the Twenty Eleven theme and installing it. The child theme was untouched and working fine.

As soon as I did this, my custom fields appeared without any further problems.

share|improve this answer

Sorry to repost here - I can't comment yet. Vote me up to 50 and help us both out.

Anyway, looking at your theme, in your stylesheet you are referencing 'Template: twentyten' instead of 'Template:twentyeleven'

Wordpress may be confused about where to look for which files. I would start by correcting that and see what happens.

share|improve this answer
    
Sorry I can't vote you up yet! My rep is not high enough. I fixed the stylesheet (Thank You!) but it had no effect. I'm going to try a vanilla install and see if I can get it working with no plugins, etc., just to make sure I'm doing it correctly. Time to start from the foundation and troubleshoot my way up. –  jennifer Aug 2 '11 at 20:49

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.