Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Need Help With Select Menus To Filter Content WordPress

  • SOLVED

I need to integrate 3 different menus:

1: Show posts tagged with specific tag in category.
2: Show authors posted in category
3: Show authors with specific custom field.



Answers (1)

2013-07-04

Arnav Joy answers:

Hi ,

i would like to work in your project ,can you show url or provide me access to your site?

please do not share any information here , send me pm .

Thanks
Arnav


Edwin comments:

Hi Arnav, will do, thank you!


Arnav Joy comments:

for first point , you can do it as follows:-

$term_id = 1 // id of the term you want to filter
$tag = 'testme'; // name of the tag you want to filter

query_posts('cat='.$term_id.'&posts_per_page=-1&tag='.$tag );

if( have_posts() ):while(have_posts()):the_post();
// your stuff like the_title();

endwhile;
else:
echo 'Sorry, no posts matched your criteria';
endif;


for point 2 you can use something


$postss = get_posts(array('posts_per_page' => -1 , 'category' => $term_id ));

foreach($postss as $postst)
{
$author[] = $postst->post_author;
}

$qauthors = array_unique($author);
if( !empty( $qauthors ) ) {
foreach( $qauthors as $author_id ) {
$user_info = get_userdata( $author_id );
echo $user_info->user_login;
echo get_the_author_meta( 'description' , $author_id );
// other stuff you can show here
}
}


and for third point , you can use something like:-

<?php
global $wpdb;
$res = $wpdb->get_col("SELECT user_id FROM ".$wpdb->prefix."usermeta WHERE meta_key = 'your_meta_key' ");
if(!empty($res )) {
foreach( $res as $author_id )
$author[] = $author_id ;


$qauthors = array_unique($author);

if( !empty( $qauthors ) ) {
foreach( $qauthors as $author_id ) {
$user_info = get_userdata( $author_id );
echo $user_info->user_login;
echo get_the_author_meta( 'description' , $author_id );
// other stuff you can show here
}
}

}


Edwin comments:

Thanks Arnav for your help on applying the fixes.