• Resolved jay.weeks

    (@jayweeks)


    I need to have multiple loops run on the index page sorted by category, this part is working. What isn’t working is the preservation of sorting posts by tags called in the url string. This is the function I’m using to query posts by category:

    <?php
    function query_single_category($kat) {
    	$category_id = get_cat_id($kat);
    	query_posts($query_string . "&cat=$category_id");
    	if ( have_posts() ) : while ( have_posts() ) : the_post();
    	include("post-content.php");
    	endwhile;
    	else :
    	endif;
    }
    ?>

    This is how I’m calling specific categories in the template:
    <?php query_single_category('residential') ?>

    Any ideas why this isn’t preserving the url string?
    I’m pretty sure my syntax is correct, I referenced the codex…would it have something to do with referencing the $query_string variable in functions.php?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jay.weeks

    (@jayweeks)

    i just tested it, and inserting that code into the index template and $query_string worked.
    Now the issue is defining this variable for use in functions.php
    Any help?

    Thread Starter jay.weeks

    (@jayweeks)

    got it

    <?php
    function query_single_category($kat) {
    	$queryString = $_SERVER['QUERY_STRING'];
    	$category_id = get_cat_id($kat);
    	query_posts($queryString . "&cat=$category_id");
    	if ( have_posts() ) : while ( have_posts() ) : the_post();
    	include("post-content.php");
    	endwhile;
    	else :
    	endif;
    }
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘multiple queries sorted by url string’ is closed to new replies.