• ignitionmedia

    (@ignitionmedia)


    Hi there
    In trying to query custom posts in the category apartmentcat so that only those that have with a meta value of australia for custom field key location are shown.

    how is this done? any help would be appreciated.
    I have the following but no where does it specify the value that is required for the query.

    <?php $values = get_post_custom_values("location"); ?>
          <?php $catinclude = 'apartmentcat=' . $cat;?>
          <?php query_posts('&' . $catinclude . ' &paged=' . $paged . '&showposts=30' .  '&orderby=menu_order'); ?>
          <?php
    		if ( have_posts() ) while ( have_posts() ) : the_post();
    		?>

    I also tried something more simply like <?php query_posts('meta_key=location&meta_value=australia&showposts=30&orderby=menu_order'); ?> but this showed no results.

Viewing 2 replies - 1 through 2 (of 2 total)
  • kuhio61

    (@kuhio61)

    I’m trying to accomplish a similar task. I want to show a specific category in the sidebar of a page using custom fields to generate the specific category

    <?php if ( get_post_meta($post->ID, 'team-category-slug', true) ) { ?>
                    <h3 class="widgettitle"><?php the_title(); ?> / Blog</h3>
    
                    <?php query_posts('category_name=<?php echo $team-category-slug; ?>&showposts=3'); ?>

    However, I still haven’t gotten this to work yet.

    Custom Field:
    Name: team-category-slug
    value: category-slug-name

    Any ideas?

    Thread Starter ignitionmedia

    (@ignitionmedia)

    Anyone?

    I’ve ended up using the following which works;

    <?php $values = get_post_custom_values("category-include"); $cat=$values[0];  ?>
          <?php $catinclude = 'apartmentcat=' . $cat;?>
          <?php query_posts('&' . $catinclude . ' &paged=' . $paged . '&showposts=20' .  '&orderby=menu_order'); ?>

    However, how do I also include another taxonomy in the $catinclude (so it uses ‘apartmentcat’ & ‘homecat’

    Does anyone know how to change the following to make it work?
    <?php $catinclude = ‘apartmentcat=’ . $cat;?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘query post with custom field’ is closed to new replies.