views:

494

answers:

1

Hi friends,

I use Barecity Theme for WordPress. i built everything, but now i need to add a single.php file to theme. now it displays all post content at homepage, I created a short_desc Custom Field. and I call it from code with;

<?php //get_post_meta($post->ID, 'short_desc', true); ?>

it is fine. but i need to display this short desc at home page listing, and the main content at details page. how can do that?

I appreciate helps!!

+1  A: 

Hello

It sounds like what you are trying to do is show a custom field that you have set on a post on the index page (which lists all the posts).

To do that you'll need to modify index.php by adding your snippet where you would like to have the short description.

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

You need to use echo to display the results from the get_post_meta function.

Depending on how your posts are setup you can also use the More button when you write your posts. This will cut off your post at a certain point that you decide and only show that short part on the index and archive pages.

Another option would be to use

<?php the_excerpt(); ?>

Which shows the first 55 words (this can be adjusted though) of the post.

Hope that helps, Paul

Paul Sheldrake
yeah, why don't use excerpt? as this is why excerpt exist in wordpress. To show you, well, obviously, the excerpt!
silent