Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter moodyjive

    (@moodyjive)

    OK that didn’t work but I was able to solve it with get_post_custom_values:

    <?php
    $cat_id = get_cat_ID('catalog');
    $artist_name_values = get_post_custom_values('artist_name');
    $args=array(
      'cat' => $cat_id,
      'meta_key' => 'artist_name',
      'meta_value' => $artist_name_values,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    //my content
    
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Now I want to have multiple values show up for the meta_key “artist_name”. Is there any way to do this?

    Thread Starter moodyjive

    (@moodyjive)

    Thanks for your help, but I am trying to pass the value from the post as the value will change on each post. Sometimes the meta_value will be “artist1” and other times it will be “artist2”

    That is why I tried:
    'meta_value' => '',

    I tried:
    'meta_value' => '$value',
    That doesn’t work.

    Is there any way to do this?

    Thread Starter moodyjive

    (@moodyjive)

    One more question ??
    I used your code as follows:

    <?php
    $cat_id = get_cat_ID('catalog');
    $args=array(
      'cat' => $cat_id,
      'meta_key' => 'artist_name',
      'meta_value' => '',
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of Posts';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    //content
    
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Unfortunately it is returning every post that contain the custom field “artist_name”
    as opposed to the certain value I have entered. Is this possible?

    Thread Starter moodyjive

    (@moodyjive)

    Sorry I wasn’t clearer

    Thread Starter moodyjive

    (@moodyjive)

    Yes I am using a custom field in each Catalog post named artist_name (key) and the value changes per post

    Thread Starter moodyjive

    (@moodyjive)

    Maybe I have been unclear. Catalog is one category, Artist is another. In Catalog I have posts like “I Wanna Rock” by Artist Zero (the artist name is a custom field BTW in Catalog). This post is tagged Artist Zero. Now I want to create an artist post (in the Artist category) called “Artist Zero” and pull in any Catalog posts tagged “Artist Zero”. In order to do this I thought i would query posts from the Catalog category that are tagged “Artist Zero”. I figured I could add a custom field in the “Artist Zero” post that would tell it to pull in those tagged items.

    Maybe I am going about this the wrong way? Should I try to query posts by the artist custom field in the Catalog section?

    Thread Starter moodyjive

    (@moodyjive)

    Michael – Thanks for this I will try tonight!
    Please forgive my ignorance but I don’t see any reference to “tag” in this code, how will it pick up the release posts that are tagged by artist? From what I see i will make custom fields in the array look like this:

    ‘meta_key’ => ‘artists_name’
    ‘meta_value’ => ”,

    But how does it pick up the tag?

    Thanks!

    I’m having the same problem. I’m wondering if it’s a Php 5 issue as I am running WP on Yahoo and they use PHP 4.

Viewing 8 replies - 1 through 8 (of 8 total)