• I’m having trouble with the query_posts function. I want to be able to only include certain posts with tag=x on all category pages, but when I do this it ruins my category pages by removing the category itself.

    What I want is when user-x is logged in he only see cat A posts tagged with x, cat B posts tagged with x etc.

    What I get is only tag x on all category pages even if it doesn’t belong to that category.

    Currently it is:

    global $bp;
    		$school_code = bp_get_profile_field_data('field=School Code&user_id='.bp_loggedin_user_id());
    		if($school_code && is_category()):
    		query_posts('tag='.$school_code);
    		endif;

    Any thoughts on the best way to do this. I’ve tried adding a category parameter for the current category page but with no luck.

Viewing 1 replies (of 1 total)
  • Thread Starter cmunns

    (@cmunns)

    This works if anyone cares for it:

    global $bp;
    		$school_code = bp_get_profile_field_data('field=School Code&user_id='.bp_loggedin_user_id());
    
    if(is_archive() || is_category()):
    	$cat_ID = get_query_var('cat');
    	query_posts('tag='.$school_code.'&cat='.$cat_ID);
    
    endif;

    It basically checks for a custom drop-down profile field for each buddypress user. It then corresponds to a post tag so only certain posts are displayed to this user.

Viewing 1 replies (of 1 total)
  • The topic ‘Query only a certain Tag without effecting Structure’ is closed to new replies.