Does anyone know why querying custom fields does not work in the Carrington mobile theme?
I´m using this:
get_post_meta($post, 'key', true)
But the query does not return anything. Anyone know why?
Added code:
while (have_posts()) : the_post();
$category = get_the_category($post);
$title = get_the_title($post->ID);
$link = get_permalink($post->ID);
$store = $category[0]->cat_name;
$volum = get_post_meta($post->ID, '2Volum', true);
$produsent = get_post_meta($post->ID, '1Produsent', true);
$pris = get_post_meta($post->ID, '3Pris', true);
echo '<a href="' . $link . '">';
echo '<div class="clear offer">';
echo '<h1 class="alignleft">' . $title . '</h1>';
echo '<p class="alignright price">' . $pris . '</p>';
echo '<p class="alignleft clearleft">' .$produsent . '</p>';
echo '<p class="alignleft">' . $volum . '</p>';
echo '</div>';
echo '</a>';
endwhile; // End the loop. Whew.
$post should be a post ID (so $post->ID if you’ve got the global $post object in scope)
the function call parameters are:
$id
: the id of the post (integer)$keyname
: a string containing the name of the custom field$single
: boolean – true means return a string for the first value, false means an array of all values for the keyThe codex page is here: http://codex.wordpress.org/Function_Reference/get_post_meta
You can also try
get_post_custom_values($key, $post_id)
Where
$key
is the ‘name’ of the custom field you want to retrieve.$post_id
is optional, and defaults to the current post.