• Resolved nitrous

    (@nitrous)


    I am trying to view posts from a certain category and then if a tag is set then show the posts and if the tag is not then dont show the posts.. But what happens is if the tag is set it shows those posts and if the tag equals nothing then it shows nothing on the page:

    address:   /?page_id=19&tager=adams
    
    if(isset($_GET['tager'])){
    $tager=$_GET['tager'];
    }
    
    if(isset($tager) || $tager!=""){
    echo postListByCategoryID($firstColumnCategoryID,$paged,$tager);
    } else{
    echo postListByCategoryID($firstColumnCategoryID);
    }
    
    function postListByCategoryID($categoryID = 0,$paged = 0,$tager="0")
    		{
    
    			$outputString = '';
    
    //if(isset($tager) && $tager!=0){
    if($tager===0 && $tager!="0"){
    			query_posts('offset='.$offset.'&cat=' . $categoryID . '&showposts=5&order=desc');
    }else{
    
    $taggy="&tag=$tager+$tager";
    	query_posts('offset='.$offset. '&cat=' . $categoryID . $taggy. '&showposts=5&order=desc');
    }

    Any help would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Wonder what that value is:

    $taggy="&tag=$tager+$tager";

    If necessary what about using the tag__in argument?

    Thread Starter nitrous

    (@nitrous)

    lol man i am happy.. i was going to try that and i was just about to start modifying my code and all of a sudden i was looking at one of my if statements when it hit me.. that doesnt make sense lol.. i changed it and now life is good again.. just needed a fresh look at it.. thanks

    working:

    function postListByCategoryID($categoryID = 0,$paged = 0,$tager="0")
    		{
    
    if($paged>0){
    $offset=$paged*10;
    $offset-=10;
    }else{
    $offset=0;
    }
    
    			$outputString = '';
    
    //if(isset($tager) && $tager!=0){
    if($tager===0 || $tager=="0"){
    			query_posts('offset='.$offset.'&cat=' . $categoryID . '&showposts=5&order=desc');
    }else{
    
    $taggy="&tag=$tager+$tager";
    ////			query_posts('offset='.$offset. $taggy. '&showposts=5&order=desc');
    			query_posts('offset='.$offset. '&cat=' . $categoryID . $taggy. '&showposts=5&order=desc');
    }
    
    			//query_posts('offset='.$offset.'&cat=' . $categoryID . '&showposts=5&order=desc');
    			$outputString .= '<ul>' . chr(10);
    			/*while (have_posts()) : the_post();
    
    			endwhile;*/
    			$outputString .= '</ul>' . chr(10);
    			return $outputString;
    		}
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Query_Posts to include tags or not’ is closed to new replies.