Custom Select Query by Authors information
-
Hello,
I am trying to make a list of authors that have the same age and live in the same city.The data about the city name and age is added on the users profile page using “Cimy User Extra Fields” plugin.
A simple way of displaying this extra fields on a page is the following;
<?php $value = get_cimyFieldValue($curauth->ID, 'AGE'); ?> <?php echo $value; ?>
To filter posts that have two same custom fields values you can use;
<?php global $wpdb; global $post; $key1 = 'labos'; $val1 = 'lpem'; $key2 = 'zvanje'; $val2 = 'Voditelj laboratorija'; $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta metacolor, $wpdb->postmeta metawgt WHERE wposts.ID = metacolor.post_id AND wposts.ID = metawgt.post_id AND (metacolor.meta_key = '$key1' AND metacolor.meta_value = '$val1') AND (metawgt.meta_key = '$key2' AND metawgt.meta_value = '$val2') AND wposts.post_type = 'post' AND wposts.post_status = 'publish' ORDER BY UPPER(wposts.post_title) ASC "; $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <?php if ($pageposts): ?> <?php global $post; ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <div class="post" id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a> </div> <?php endforeach; ?> <?php endif; ?>
How can I now show some authors names that have two same values added by the “Cimy User Extra Fields” plugin in their profile page?
Thank you
- The topic ‘Custom Select Query by Authors information’ is closed to new replies.