Support » Plugins » Hacks » Dynamic category id and tag slug in query_posts array

  • Hi there,

    We’re working on a directory listing site and are having trouble with a piece of code.

    query_posts( array( 'category__and' => array(11), 'surrounding_suburbs' => 'abbotsford-s', 'posts_per_page' => 5 ) );

    This is to be displayed on a results page determined by category and tag, eg.

    (‘surrounding_suburbs’ is a the custom taxonomy).

    What we need to happen:

    – The category needs to be loaded in to the query dynamically: tried using <?php echo get_category_link( $category_id ); ?> but then that seemed to stop the ‘surrounding_suburbs’ part working at all

    – The surrounding_suburbs part needs to dynamically load the tag slug, then add an extra ‘-s’ on the end. eg. the tag slug is ‘abbotsford’, and the custom taxonomy slug would be ‘abbotsford-s’.

    This might all be a bit confusing and I might not have explained it properly, but any assistance would be greatly appreciated!

  • The topic ‘Dynamic category id and tag slug in query_posts array’ is closed to new replies.