Displaying Custom Fields In Post
AnonymousJuly 3, 2011 at 2:26 am #1253
I need help with displaying custom fields in posts.
I used a CSV importer plugin to import a bunch of CSV files for adding posts to my site. The import contains a number of custom fields labelled “custom_field_1”, “custom_field_2”, etc …
I can see the fields and the imported values that correspond to these fields in “Edit Post”.
I have spent hours pouring over Codex information on how to add custom fields to a post and trying to insert
<?php the_meta(); ?>into the loop.php file in the Graphene theme so that the custom fields show up after each single post content.
The issues I am experiencing are as follows:
1) I am not able to get the custom fields to show up after the post. I can get them to show up before the post (e.g. category, date, print, etc…), before the title, after the tile, after the comments, outside the post, etc … but not after the post content. Where do I insert this code to make the information show up after each single post?
2) When the code shows up on the page, it shows up as “custom_field_1: 30 minutes custom_field_2: John Smith, custom_field_3: http://moreinformationlink, etc …”
What I would like it to do, is display the information as a list with the key values showing up as:
Duration: 30 minutes
Author: John Smith
More Details: Title of post as anchor link with URL
instead of …
custom_field_1: 30 minutes
custom_field_2: John Smith
custom_field_3: URL (not anchor text link)
How can I do the above? I have been doing my head in trying to figure this out.
Any help would be very much appreciated.
It looks to me like your site is composed entirely of pages, rather than posts. Am I right?
I am curious because I have always wondered about custom fields as well, but my understanding is that they are unique to posts, and not pages. I am probably wrong about this (the codex is not clear), but hopefully someone here can offer some wisdom.
Custom fields are not displayed anywhere by default. You would need to manually add them in the theme (or by using a child theme).
Some themes (and plugins) do have built-in custom fields – in fact this is how Graphene provides the per-post and per-page options. Other than those built-in custom fields, you would have to manually add (and style) your custom fields yourself.
- You must be logged in to reply to this topic.