Well, after many search, I found that one way of doing that is to use query_posts('meta_key=color&meta_value=blue'); just before if (have_posts()) : to make it query_posts('meta_key=color&meta_value=blue'); if (have_posts()) :
The problem, this will change the default behaviour of my archive.php.
What I have in the beginning of my archive.php is (theme News Magazine Theme 640)
<?php
is_tag();
if (have_posts()) :
?>
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php /* If this is a category archive */ if (is_category()) { ?>
<h1> ‘<?php single_cat_title(); ?>’ <?php _e("Archives",'NewsMagazineTheme640'); ?></h1>
<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
<h1><?php _e("Posts Tagged",'NewsMagazineTheme640'); ?> ‘<?php single_tag_title(); ?>’</h1>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<h1><?php _e("Archive for",'NewsMagazineTheme640'); ?> <?php the_time('F jS, Y'); ?></h1>
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<h1><?php _e("Archive for",'NewsMagazineTheme640'); ?> <?php the_time('F, Y'); ?></h1>
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h1><?php _e("Archive for",'NewsMagazineTheme640'); ?> <?php the_time('Y'); ?></h1>
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<h1><?php _e("Author Archive",'NewsMagazineTheme640'); ?></h1>
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<h1><?php _e("Blog Archives",'NewsMagazineTheme640'); ?></h1>
<?php } ?>
What I see here, I am having different archive page based on different conditions passed through different functions here, like is_author(), is_year(), etc. Logically, thus if we have another function like is_special($meta_key) we could use the existing archive page for displaying post filtered by their special field values.
The questions:
- Now, where can I create that function? In function.php?
- Then, how to make the page understand that now he should use
is_special($meta_key)function, and not another one? - Next question, how to pass the variable now that I am using
the_permalink()for url generation? - How can I keep the pagination function.
Any help will be appreciated. Sorry if I have bombarded with too many shots.