You can get custom field values with get_post_meta
. Like so…
<?php
$wp_query = new WP_Query();
$wp_query->query('post_type=customtype&showposts=10'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
the_title(); // <- works
if( $some_meta = get_post_meta( get_the_ID(), 'the_meta_key_you_want', true )
{
// you could put other formatting here.
echo $some_meta;
}
endwhile;
You’ll need to change the_meta_key_you_want
in the call to get_post_meta
, of course.
For a custom taxonomy, you’ll want to use get_the_terms
or the_terms
. the_terms
is a bit more like the_tags
or the_category
, it spits out HTML for you. get_the_terms
will just return an array (a list) of the term objects.
Here’s an example of get_the_terms
. The Codex entry for it also has some good examples. You’ll have to change your_taxonomy
, of course.
<?php
$wp_query = new WP_Query();
$wp_query->query('post_type=customtype&showposts=10'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
the_title(); // <- works
$terms = get_the_terms( get_the_ID(), 'your_taxonomy' );
if( $terms && ! is_wp_error( $terms ) )
{
foreach( $terms as $t )
{
echo '<a href="' . get_term_link( $t->slug, 'your_taxonomy' ) . '">' . esc_html( $t->name ) . '</a>';
}
}
endwhile;