symbiose
Member
Posted 2 years ago #
I am about the create a template page with a full list of all the post headlines of the blog (code follows ...).
Now I want to have after each post the value of a custom field. The name of the custom field is "Region" and a Value for example is "London" ...
So I have to add something in or after
<?php wp_get_archives('type=alpha'); ?>
right?
<?php
/*
Template Name: List
*/
?>
<?php get_header(); ?>
<div class="content">
<h2><?php the_title(); ?></h2>
<div class="post">
<?php wp_get_archives('type=alpha'); ?>
</div>
</div>
<?php
get_sidebar();
get_footer();
?>
Can't do that with wp_get_archives. You'd need to do your own query_posts() loop and then display the custom field for each post.
Related:
Custom Fields
symbiose
Member
Posted 2 years ago #
is query_posts() to generate a custom new list?
and then i have to get get_posts() ?
This will list all post titles and the associated custom fields:
<?php
$args=array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo 'List of Posts';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
the_meta();
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
symbiose
Member
Posted 2 years ago #
wow, thanks a lot!
thanks for the learning ...
frescova
Member
Posted 1 year ago #
Sweet - was looking for something like this for a while. Just a quick question, how do I limit the query from only returning posts that belong to a specific category?
I tried adding:
'post_category' => array(68)
to the args array but it did not filter my results to limit posts only from category ID 68...
Thanks in advance.
frescova
Member
Posted 1 year ago #
Please disregard - I ust figured out I should use:
'cat' => 68,
instead of:
'post_category' => array(68)