Problem with query_posts for a custom taxonomy in theme options

I see three things.

if ( function_exists( 'of_get_option' ) ) :
    query_posts( 'cat=" . $homepage_feature = of_get_option( "homepage_feature' ) . '&posts_per_page=3' ); 
  1. You have a syntax error. There is no endif;. Maybe that is a typo, but maybe not. If you are trying to write a one-line if, remove the colon.
  2. Your title states “custom taxonomy”. cat= is for categories, not general taxonomies. See the Codex.
  3. Use WP_Query, not query_posts

Assuming the rest of the code works, and assuming I am reading it right, your query should be:

if ( function_exists( 'of_get_option' ) ) {
  $args = array(
    'posts_per_page' => 3,
    'tax_query' => array(
         array(
            'taxonomy' => 'your-taxonomy-name',
            'field' => 'id', // or slug; I don't know which you have
            'terms' => of_get_option( 'homepage_feature' )
         )
     )
  );
  $my_qry = new WP_Query($args); 
}

Leave a Comment