Support » Plugins » custom taxonomy metadata

Viewing 1 replies (of 1 total)
  • James


    Okay since there were no answers I found a solution on my own. What I ended up doing was writing a custom sql query to pull the data I needed and since I had multiple points of data and the query was a bit lengthy I made a function out of it that I could just pass the field names and post ID that I wanted and it would return them. I am now in the process of making them links so they can pull all related posts as well. Anyways here is the function and its use in case it ill help anyone else.

    function meta_custom( $myid, $keyto ) {
    global $wpdb;
     $qstr = "
    SELECT $wpdb->taxonomymeta.meta_value
    FROM $wpdb->taxonomymeta, $wpdb->term_taxonomy, $wpdb->term_relationships
    WHERE $wpdb->taxonomymeta.taxonomy_id = $wpdb->term_taxonomy.term_id
    AND $wpdb->term_taxonomy.term_id = $wpdb->term_relationships.term_taxonomy_id
    AND $wpdb->term_relationships.object_id = $myid
    AND $wpdb->taxonomymeta.meta_key = $keyto ";
    $retkey = $wpdb->get_results($qstr);
        foreach ($retkey as $i => $values)  {
            foreach ($values as $key => $value) {
                echo $value;

    And it usage in the page.

    <?php meta_custom( $post->ID, "'wregion'" ); ?>

    Note: wregion is the name of the field I am pulling notice the double quotes. Wont work otherwise.

    I am by no means a PHP programmer in fact this is the first piece of PHP code Ive ever written. You know necessity is the mother of invention. 😉 Anyways someone else may be able to clean it up a bit.But it works well.

    BTW this code works with the plugin I have for taxonomies which is Ultimate CMS which I highly recommend. Very nice.

Viewing 1 replies (of 1 total)
  • The topic ‘custom taxonomy metadata’ is closed to new replies.